Skip to content

Invalid CMS data causes Unity Editor crash (no graceful error handling) #12

@cuongvminwave

Description

@cuongvminwave

Summary

When a CMS condition contains an invalid value (e.g. malformed version string), libBalancyCore.dll throws an unhandled std::_Xinvalid_argument during initManagers, crashing the Unity Editor instead of logging an error and continuing.

Environment

Balancy SDK: co.balancy.unity@87014887ed (1.6.23)
Unity: 2022.3.62f3
Platform: Windows 11 (Editor)
Game ID: 8fa19b9c-e82b-11ef-bb95-1fec53a055ba

Steps to Reproduce

In Balancy CMS, create an AppVersion condition with an invalid version string (e.g. "8..9.0" — double dot)
Assign this condition to any And/Or chain used by a GameOffer or GameEvent
Run Play mode in Unity Editor

Expected Behavior

Balancy should log a warning (e.g. "Invalid AppVersion value: '8..9.0', skipping condition") and continue initialization. A misconfigured condition on the server must never crash the client.

Actual Behavior

Unity Editor crashes immediately during initManagers with no recoverable error:

[WARNING] Dict not found SmartObjects.Conditions.TimeRange
!!!! initManagers !!!!
Crash!!!
0x00007FFC96CB1B6A (KERNELBASE) RaiseException
0x00007FFC7E715267 (VCRUNTIME140) CxxThrowException
0x00007FFC7D8D94D2 (MSVCP140) std::_Xinvalid_argument
libBalancyCore → balancyCustomConditionForceUpdate (×6 frames)
Balancy.Controller → InvokeInMainThread (Controller.cs:710)
Balancy.UnityMainThreadDispatcher → ProcessQueue / Update

Root Cause

Local cached condition data:

// SmartObjects.Conditions.AppVersion.json
{"list":[{"unnyId":"5264","comparison":2,"value":"8..9.0"}]}

Value "8..9.0" (double dot) is not a valid version string. The native balancyCustomConditionForceUpdate attempts to parse it and throws std::_Xinvalid_argument, which is not caught, propagating as a fatal crash.

Impact

  • Any typo in a CMS condition value takes down the entire Editor session
  • Developers lose all unsaved work; no log indicates which condition is at fault
  • Root cause is very hard to find (requires manual inspection of local JSON cache files)

Request

  1. Wrap condition parsing in a try/catch inside balancyCustomConditionForceUpdate — log the offending condition's unnyId and value, then skip it gracefully
  2. Surface the bad condition in the C# layer with a clear error: "[Balancy] Condition {unnyId} has invalid value '{value}' for type {type}, skipping"
  3. Bonus: Add server-side validation in the CMS editor to reject malformed version strings before they reach clients

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions