gitlabhq/gitlabhq · error · Gitlab::Graphql::Errors::ArgumentError

if the linkType argument is provided, it cannot be null

Error message

if the linkType argument is provided, it cannot be null

What it means

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.

Source

Thrown at app/graphql/mutations/release_asset_links/update.rb:41

        required: false,
        description: 'URL of the asset link.'

      argument :direct_asset_path, GraphQL::Types::String,
        required: false, as: :filepath,
        description: 'Relative path for a direct asset link.'

      argument :link_type, Types::ReleaseAssetLinkTypeEnum,
        required: false,
        description: 'Type of the asset link.'

      field :link,
        Types::ReleaseAssetLinkType,
        null: true,
        description: 'Asset link after mutation.'

      def ready?(**args)
        if args.key?(:link_type) && args[:link_type].nil?
          raise Gitlab::Graphql::Errors::ArgumentError,
            'if the linkType argument is provided, it cannot be null'
        end

        super
      end

      def resolve(id:, **link_attrs)
        link = authorized_find!(id: id)

        result = ::Releases::Links::UpdateService
          .new(link.release, current_user, link_attrs)
          .execute(link)

        if result.success?
          { link: result.payload[:link], errors: [] }
        else
          { link: nil, errors: result.message }
        end

View on GitHub (pinned to 55ee20384a)

Solutions

  1. Remove the linkType key from the variables object instead of setting it to null
  2. Use a client setting that strips nulls from input objects (e.g. omit undefined values before JSON.stringify)
  3. To leave the type unchanged, simply do not send linkType

Example fix

// before
const input = { id, name, linkType: null }; // serializer emitted null

// after
const input = { id, name };
// or explicitly: delete input.linkType;
Defensive patterns

Strategy: validation

Validate before calling

function stripNulls(input) {
  return Object.fromEntries(Object.entries(input).filter(([, v]) => v !== null));
}
const vars = stripNulls({ id, name, linkType: maybeType }); // linkType key vanishes when null

Try / catch

On /cannot be null/, remove the linkType key from variables (do not set it to null) and re-send.

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21). Data as JSON: /api/errors/f64e2667fd4d86ec. Report an issue: GitHub.