{"record":{"id":"f64e2667fd4d86ec","repo":"gitlabhq/gitlabhq","slug":"if-the-linktype-argument-is-provided-it-cannot-be","errorCode":null,"errorMessage":"if the linkType argument is provided, it cannot be null","messagePattern":"if the linkType argument is provided, it cannot be null","errorType":"exception","errorClass":"Gitlab::Graphql::Errors::ArgumentError","httpStatus":null,"severity":"error","filePath":"app/graphql/mutations/release_asset_links/update.rb","lineNumber":41,"sourceCode":"        required: false,\n        description: 'URL of the asset link.'\n\n      argument :direct_asset_path, GraphQL::Types::String,\n        required: false, as: :filepath,\n        description: 'Relative path for a direct asset link.'\n\n      argument :link_type, Types::ReleaseAssetLinkTypeEnum,\n        required: false,\n        description: 'Type of the asset link.'\n\n      field :link,\n        Types::ReleaseAssetLinkType,\n        null: true,\n        description: 'Asset link after mutation.'\n\n      def ready?(**args)\n        if args.key?(:link_type) && args[:link_type].nil?\n          raise Gitlab::Graphql::Errors::ArgumentError,\n            'if the linkType argument is provided, it cannot be null'\n        end\n\n        super\n      end\n\n      def resolve(id:, **link_attrs)\n        link = authorized_find!(id: id)\n\n        result = ::Releases::Links::UpdateService\n          .new(link.release, current_user, link_attrs)\n          .execute(link)\n\n        if result.success?\n          { link: result.payload[:link], errors: [] }\n        else\n          { link: nil, errors: result.message }\n        end","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/gitlabhq/gitlabhq/blob/55ee20384a1f55cb0e362dee1d07149613b1b9bf/app/graphql/mutations/release_asset_links/update.rb#L23-L59","documentation":"UpdateReleaseAssetLink uses a GraphQL idiom for 'nullable but not clearable': linkType is optional, but explicitly passing null would mean 'erase the type', which the service does not support. ready? checks args.key?(:link_type) && args[:link_type].nil? and raises ArgumentError 'if the linkType argument is provided, it cannot be null'. Omitting the field entirely means 'leave unchanged'; null is rejected.","triggerScenarios":"Calling updateReleaseAssetLink with linkType: null in the JSON variables. This commonly happens when a client serializer includes null fields by default instead of omitting absent keys.","commonSituations":"GraphQL clients (e.g. some JS/Python serializers) that emit every known field with null when building input objects; spread syntax copying a partially-filled template object; trying to 'reset' a link to having no type via null.","solutions":["Remove the linkType key from the variables object instead of setting it to null","Use a client setting that strips nulls from input objects (e.g. omit undefined values before JSON.stringify)","To leave the type unchanged, simply do not send linkType"],"exampleFix":"// before\nconst input = { id, name, linkType: null }; // serializer emitted null\n\n// after\nconst input = { id, name };\n// or explicitly: delete input.linkType;","handlingStrategy":"validation","validationCode":"function stripNulls(input) {\n  return Object.fromEntries(Object.entries(input).filter(([, v]) => v !== null));\n}\nconst vars = stripNulls({ id, name, linkType: maybeType }); // linkType key vanishes when null","typeGuard":null,"tryCatchPattern":"On /cannot be null/, remove the linkType key from variables (do not set it to null) and re-send.","preventionTips":["Configure your GraphQL client to omit null-valued keys in input objects","Model 'clear' intent explicitly instead of relying on null"],"tags":["gitlab","graphql","releases","asset-links","explicit-null"],"backgroundTag":"graphql-explicit-null-argument","analyzedSha":"55ee20384a1f55cb0e362dee1d07149613b1b9bf","analyzedAt":"2026-08-21T14:22:27.782Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}