{"record":{"id":"0b1c333b2bb820ed","repo":"opf/openproject","slug":"value-for-name-must-be-one-of-allowed-join","errorCode":null,"errorMessage":"Value for #{name} must be one of #{allowed.join(', ')} but is #{value}","messagePattern":"Value for #(.+?) must be one of #(.+?) but is #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"critical","filePath":"config/constants/settings/definition.rb","lineNumber":1564,"sourceCode":"\n    def persist_on_first_read?\n      persist_on_first_read\n    end\n\n    def unprefixed_env_var_name_allowed?\n      # Configuration values could be overridden with unprefixed env var\n      # names before being harmonized (PR#10296). Using unprefixed en var\n      # is deprecated and will be removed in 13.0.\n      # Configuration are recognized by not being writable.\n      !writable\n    end\n\n    def override_value(other_value)\n      self.value = coerce(other_value)\n      if valid_for?(value)\n        self.writable = false\n      else\n        raise ArgumentError, \"Value for #{name} must be one of #{allowed.join(', ')} but is #{value}\"\n      end\n    end\n\n    def valid_for?(value)\n      return true if allowed.nil?\n\n      # TODO: it would make sense to also check the type of the value (e.g. boolean).\n      # But as using e.g. 0 for a boolean is quite common, that would break.\n      if format == :array\n        (value - allowed).empty?\n      else\n        allowed.include?(value)\n      end\n    end\n\n    def allowed\n      if @allowed.respond_to?(:call)\n        @allowed.call","sourceCodeStart":1546,"sourceCodeEnd":1582,"githubUrl":"https://github.com/opf/openproject/blob/d9742c43f3424c34b63550f8c03f201fe5c3040c/config/constants/settings/definition.rb#L1546-L1582","documentation":"Setting definitions may declare an allowed list (Settings::Definition#valid_for?); for example log_level allows debug/info/warn/error/fatal and storage settings allow symbol sets like file/fog. When a value from configuration.yml or an OPENPROJECT_* environment override is applied via override_value, it is coerced and validated; a value outside the list raises ArgumentError naming the setting, the permitted values, and the value received. The raise happens while settings are resolved, i.e. at boot or on first access of that setting.","triggerScenarios":"Setting an enumerated setting to a non-permitted value through its env var or configuration.yml, e.g. OPENPROJECT_LOG__LEVEL=verbose (allowed: debug, info, warn, error, fatal); array-format settings where any element is outside the allowed set ((value - allowed) not empty); range-allowed settings (e.g. allowed: 0..120, 1000..10_000) exceeded.","commonSituations":"Typos in env var values in docker-compose/Kubernetes manifests; configs copied between OpenProject versions where an allowed value was removed or renamed; numeric settings pushed past their configured range; values with the wrong case or whitespace so the include? check fails.","solutions":["Read the message — it lists the setting name, every allowed value, and what you supplied; pick one of the allowed values","Fix the offending entry in the environment (remember nested names use double underscores, e.g. OPENPROJECT_LOG__LEVEL) or in config/configuration.yml","Remove the override entirely to fall back to the setting's default","After upgrading OpenProject, diff config/constants/settings/definition.rb for the setting's allowed list — lists change between versions"],"exampleFix":"# before — boot fails with\n#   ArgumentError: Value for log_level must be one of debug, info, warn, error, fatal but is verbose\nenvironment:\n  OPENPROJECT_LOG__LEVEL: \"verbose\"\n\n# after\nenvironment:\n  OPENPROJECT_LOG__LEVEL: \"debug\"","handlingStrategy":"validation","validationCode":"# deploy-time guard: check enumerated overrides against the same allowed lists\n# the app uses (allowed values are printed in the error message and defined in\n# config/constants/settings/definition.rb)\nallowed = %w[debug info warn error fatal] # for log_level — take the list per setting\nvalue = ENV.fetch(\"OPENPROJECT_LOG__LEVEL\", nil)\nif value && !allowed.include?(value)\n  abort \"OPENPROJECT_LOG__LEVEL must be one of #{allowed.join(', ')} (got #{value})\"\nend","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Lint every OPENPROJECT_* value in CI against the current version's definition.rb before deploying","Prefer removing an override over guessing values — defaults are always valid","After upgrades, re-read the allowed lists for the settings you override; values get removed and renamed across versions"],"tags":["configuration","settings","environment-variables","boot","validation"],"backgroundTag":"config-value-validation-failed","analyzedSha":"d9742c43f3424c34b63550f8c03f201fe5c3040c","analyzedAt":"2026-08-21T14:40:06.829Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}