open-feature/flagd

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

開放

#1,487 建立於 2024年12月19日

 (3 則留言) (2 個反應) (0 位負責人)Go (118 個分叉)github user discovery
enhancementgood first issuehelp wantedv1.0-prereq

倉庫指標

星標
 (925 顆星)
PR 合併指標
 (平均合併 3天 9小時) (30 天內合併 8 個 PR)

描述

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
        }
      }
    }
  }

貢獻者指南