config3-scenario.md 3.3 KB

Config 3: Empty Values & Mixed Content

Scenario

Corner case testing untuk validasi parser behavior dengan empty values, mixed arrays (kombinasi string dan object), dan special characters.

Use Case

Testing edge cases yang mungkin ditemukan di production: config dengan optional values, mixed content types, dan special characters dalam values.


Input: CONFIG3.yaml

payment:
  provider: stripe
  ApiSecret: 
  EmptyObject:
  NestedEmpty:
    level1:
    level2:
      level3: 
  MixedArray:
    - simpleString1
    - name: objectInArray
      value: 123
    - simpleString2
    - key: anotherObject
      type: TEST
      subconfig:
  StatusCodes:
    - 200
    - 201
    - 204
  SpecialChars: "value:with:colons"
  MultilineValue: TrxUrlMethod || ':' || relurl || ':' || minifiedMsg
  NullishValues:
    empty: 
    zero: 0
    false: false

Output: hasilParseConfig3.json

{
  "payment": {
    "provider": "stripe",
    "ApiSecret": "",
    "EmptyObject": "",
    "NestedEmpty": {
      "level1": "",
      "level2": {
        "level3": ""
      }
    },
    "MixedArray": [
      "simpleString1",
      {
        "name": "objectInArray",
        "value": "123",
        "subconfig": ""
      },
      "simpleString2",
      {
        "key": "anotherObject",
        "type": "TEST"
      }
    ],
    "StatusCodes": ["200", "201", "204"],
    "SpecialChars": "value:with:colons",
    "MultilineValue": "TrxUrlMethod || ':' || relurl || ':' || minifiedMsg",
    "NullishValues": {
      "empty": "",
      "zero": "0",
      "false": "false"
    }
  }
}

ESQL Usage

DECLARE config REFERENCE TO Environment.Variables;
DECLARE success BOOLEAN;

CALL ACE_LIB.getConfig(
    'EDGE_CASE_CONFIG',
    'payment',
    '/path/to/CONFIG3.yaml',
    '600',
    config
) INTO success;

IF success THEN
    -- Empty values menjadi empty string
    DECLARE apiSecret CHARACTER config.ApiSecret;  -- ""
    
    -- Nested empty values
    DECLARE level3 CHARACTER config.NestedEmpty.level2.level3;  -- ""
    
    -- Mixed array: bisa string atau object
    DECLARE itemRef REFERENCE TO config.MixedArray[1];
    WHILE LASTMOVE(itemRef) DO
        -- Check if it's object or string
        IF itemRef.name IS NOT NULL THEN
            -- It's an object
            DECLARE itemName CHARACTER itemRef.name;
        ELSE
            -- It's a simple string
            DECLARE itemValue CHARACTER itemRef;
        END IF;
        MOVE itemRef NEXTSIBLING;
    END WHILE;
    
    -- Special characters preserved
    DECLARE specialVal CHARACTER config.SpecialChars;
    -- Value: "value:with:colons"
END IF;

Key Features Tested

✅ Empty string values (ApiSecret:)
✅ Nested empty objects
✅ Mixed arrays (strings and objects together)
✅ Special characters in values (: tidak break parser)
✅ Numeric values as strings ("0", "200")
✅ Boolean-like values as strings ("false")
✅ Complex expression strings


Important Notes

  • Empty values (key:) → empty string ""
  • All numeric values → parsed as string ("0", "123")
  • Boolean values → parsed as string ("false", "true")
  • Special chars in value → preserved as-is
  • Mixed arrays → valid dan bisa di-handle

⬅️ Back to README