flaviostutz / ruller-dsl-feature-flag

A feature flag engine that can be used to enable, change or rollout features of a system dynamically based on system or user attributes
MIT License
2 stars 6 forks source link

Malformed json #25

Open maximillianfx opened 4 years ago

maximillianfx commented 4 years ago

When we run the RullerDSL with a malformed json the output don't looks pretty and assertful:

Step 14/27 : RUN ruller-dsl-feature-flag     --log-level=info     --source=/app/domains.json,/app/menu.json,/app/screens.json     --target=/app/rules.go     --condition-debug=true
 ---> Running in 6fe7edb2f928
time="2020-08-28T21:35:46Z" level=info msg="Starting Ruller DSL Feature Flag code generator"
time="2020-08-28T21:35:46Z" level=info msg="Loading json rules /app/domains.json"
time="2020-08-28T21:35:46Z" level=info msg="Loading json rules /app/menu.json"
time="2020-08-28T21:35:46Z" level=info msg="Loading json rules /app/screens.json"
panic: assignment to entry in nil map

goroutine 1 [running]:
main.traverseConditionCode(0x0, 0x86db73, 0x4, 0xc00011bbe8, 0x7ffc76d09ecc, 0x4, 0xc000166df8, 0x4, 0x0, 0x0)
    /app/main.go:293 +0x715
main.main()
    /app/main.go:143 +0x1dbc
ERROR: Service 'sample' failed to build: The command '/bin/sh -c ruller-dsl-feature-flag     --log-level=info     --source=/app/domains.json,/app/menu.json,/app/screens.json     --target=/app/rules.go     --condition-debug=true' returned a non-zero code: 2

The json needs to be correct in your structure, without comma breaks in wrong positions:

"_items": [
        {
            "label": "Conta corrente",
            "_condition": "contains(group:grupos,input:grupo)",
            "_items": [
                {
                    "label": "Consulta",
                    "_items": [
                        {
                            "label": "Saldo",
                            "_condition": "contains(group:perfis,input:perfil)", <- here
                        }
                    ]
                }
            ]
        }
    ]

What do you think to add some function/lib that verify the correct structure of json before the data processing?