open-feature/flagd

[FEATURE] provider option to reject flag set with invalid rules

Open

#1487 aperta il 19 dic 2024

Vedi su GitHub
 (3 commenti) (2 reazioni) (0 assegnatari)Go (118 fork)github user discovery
enhancementgood first issuehelp wantedv1.0-prereq

Metriche repository

Star
 (925 star)
Metriche merge PR
 (Merge medio 9g 4h) (12 PR mergiate in 30 g)

Descrizione

Moved to FEATURE as discussed below.

Observed behavior

When using a flag config that does not conform to the schema, flagd shows the following warning in the logs but accepts the config nevertheless without error: 2024-12-19T10:26:53.980+0100 warn evaluator/json.go:114 flag definition does not conform to the schema; validation errors: 1:flags.is-enabled: Must validate one and only one schema (oneOf) 2:flags.is-enabled.variants.off: Invalid type. Expected: number, given: boolean 3:flags.is-enabled: Must validate all the schemas (allOf)

This leads to inconsistent behavior during evaluations (https://github.com/open-feature/flagd/issues/1481)

Expected Behavior

There are a couple of behaviors that could make sense:

  • when flag config validation fails, return an error and don't accept the updated config, essentially keep working with whatever was already in the flag store (preferred)
  • possibly, accept only parts of the config that conform to the schema and return a warning / error (probably not a good idea)

Steps to reproduce

Use the following flag config. The variants have mismatched types (number and boolean).

{
    "$schema": "https://flagd.dev/schema/v0/flags.json",
    "flags": {
      "is-enabled": {
        "defaultVariant": "off",
        "state": "ENABLED",
        "targeting": {
          "if": [
            {
              "<": [
                {
                  "%": [
                    {
                      "var": "request_id"
                    },
                    1000
                  ]
                },
                100
              ]
            },
            "on",
            "off"
          ]
        },
        "variants": {
          "on": 1,
          "off": false
        }
      }
    }
  }

Guida contributor