{"record":{"id":"3d5e3c39bb684c2f","repo":"ruby-grape/grape","slug":"required-field-not-exist-field","errorCode":null,"errorMessage":"required field not exist: #{field}","messagePattern":"required field not exist: #(.+?)","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"lib/grape/validations/params_scope.rb","lineNumber":244,"sourceCode":"      #   renamed name, with the +as: ...+ semantic)\n      def push_renamed_param(path, new_name)\n        @api.inheritable_setting.add_route_renamed_param(Array(path).map(&:to_s), new_name.to_s)\n      end\n\n      def require_required_and_optional_fields(context, using:, except: nil)\n        except_fields = Array.wrap(except)\n        using_fields = using.keys.delete_if { |f| except_fields.include?(f) }\n\n        if context == :all\n          optional_fields = except_fields\n          required_fields = using_fields\n        else # context == :none\n          required_fields = except_fields\n          optional_fields = using_fields\n        end\n        required_fields.each do |field|\n          field_opts = using[field]\n          raise ArgumentError, \"required field not exist: #{field}\" unless field_opts\n\n          requires(field, **field_opts)\n        end\n        optional_fields.each do |field|\n          field_opts = using[field]\n          optional(field, **field_opts) if field_opts\n        end\n      end\n\n      def require_optional_fields(context, using:, except: nil)\n        optional_fields = using.keys\n        unless context == :all\n          except_fields = Array.wrap(except)\n          optional_fields.delete_if { |f| except_fields.include?(f) }\n        end\n        optional_fields.each do |field|\n          field_opts = using[field]\n          optional(field, **field_opts) if field_opts","sourceCodeStart":226,"sourceCodeEnd":262,"githubUrl":"https://github.com/ruby-grape/grape/blob/22d7975629846a3c0c7bd2b34e140a7a1b4af8f6/lib/grape/validations/params_scope.rb#L226-L262","documentation":"With `requires ... using: HASH, except: [...]`, Grape re-declares the using-hash fields, and in the 'none' context (:none means only the except-ed fields become required) every field listed in `except` must exist in the `using` hash. When an except entry has no entry in using, Grape cannot build a `requires` for it and raises 'required field not exist: X' at definition time.","triggerScenarios":"`requires :filters, using: { name: { type: String }, age: { type: Integer } }, except: [:email]` - :email is not a key of using. Renaming fields in the using hash but not in except. Passing except as a single symbol that does not match any using key.","commonSituations":"Maintaining a shared using/except allow-list as params evolve. Copying an except list from another endpoint with a different using hash. Field renamed in a schema refactor.","solutions":["Remove the stale field from `except`.","Add the field to the `using` hash if it should still be declared: `using: { ..., email: { type: String } }`.","Keep using and except in sync by deriving except from using.keys in test/setup code."],"exampleFix":"# before\nrequires :filters,\n        using: { name: { type: String }, age: { type: Integer } },\n        except: [:email] # raises 'required field not exist: email'\n\n# after\nrequires :filters,\n        using: { name: { type: String }, age: { type: Integer }, email: { type: String } },\n        except: [:email]","handlingStrategy":"validation","validationCode":"missing = except_fields - using_hash.keys\nraise ArgumentError, \"except fields missing from using: #{missing.join(', ')}\" if missing.any?\n\nrequires :filters, using: using_hash, except: except_fields","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep using/except pairs adjacent and derived from one source (e.g. a constant keys list).","Run `except - using.keys` checks in a spec that boots the endpoint.","Rename fields in both places in the same commit."],"tags":["grape","params","using","except","field-mismatch"],"backgroundTag":"unknown-except-field","analyzedSha":"22d7975629846a3c0c7bd2b34e140a7a1b4af8f6","analyzedAt":"2026-08-21T17:03:54.627Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}