gitlabhq/gitlabhq · error · GraphQL::CoercionError
#{value.inspect} is not a Gitlab Global ID
Error message
#{value.inspect} is not a Gitlab Global ID What it means
Types::GlobalIDType.coerce_input (app/graphql/types/global_id_type.rb:32) raises GraphQL::CoercionError when the string parses as a Global ID but its app segment differs from GlobalID.app (i.e. anything other than "gitlab"). So "gid://other-app/Issue/1" is well-formed but foreign, and GitLab rejects it to prevent cross-application id confusion.
Source
Thrown at app/graphql/types/global_id_type.rb:32
`1` is the record id as per the id in the db table.
Global identifiers are encoded as strings.
DESC
# @param value [GID]
# @return [String]
def self.coerce_result(value, _ctx)
::Gitlab::GlobalId.as_global_id(value).to_s
end
# @param value [String]
# @return [GID]
def self.coerce_input(value, _ctx)
return if value.nil?
gid = GlobalID.parse(value)
raise GraphQL::CoercionError, "#{value.inspect} is not a valid Global ID" if gid.nil?
raise GraphQL::CoercionError, "#{value.inspect} is not a Gitlab Global ID" unless gid.app == GlobalID.app
gid
end
# Construct a restricted type, that can only be inhabited by an ID of
# a given model class.
def self.[](model_class)
@id_types ||= {
# WorkItem has a special class as we want to allow IssueID
# on WorkItemID while we transition into work items
::WorkItem => ::Types::WorkItemIdType
}
@id_types[model_class] ||= Class.new(self) do
model_name = model_class.name
graphql_name model_name_to_graphql_name(model_name)
description <<~MD.stripView on GitHub (pinned to 55ee20384a)
Solutions
- Rebuild the id with the gitlab app: "gid://gitlab/#{gid.model_name}/#{gid.model_id}".
- If producing ids in Ruby, use the model's to_global_id (which uses the app configured in this Rails app).
- Audit producers/consumers so only gitlab-app gids flow into the GitLab GraphQL API.
Example fix
# before
{"id": "gid://foo-app/Issue/1"}
# after
{"id": "gid://gitlab/Issue/1"} Defensive patterns
Strategy: type-guard
Validate before calling
const ok = /^gid:\/\/gitlab\//.test(id);
if (!ok) throw new RangeError('Global ID must use the gitlab app segment'); Type guard
function isGitlabAppGid(s) { return typeof s === 'string' && s.startsWith('gid://gitlab/'); } Prevention
- Produce gids only via to_global_id (or the documented gid://gitlab/ prefix).
- Do not feed GlobalIDs minted by other Rails apps into GitLab's API.
- Validate the app segment when ids arrive from external systems.
When it happens
Trigger: Passing a Global ID minted by another Rails app (gid://my-app/User/1) or a hand-typed gid with a wrong app segment (gid://github/Issue/1) to any GitLab ID argument.
Common situations: Shared libraries that serialize GlobalIDs from multiple apps; copy-paste from tutorials using placeholder apps; environments where GlobalID.app was customized on the producing side.
Related errors
- #{value.inspect} is not a valid Global ID
- Contact #{contact_id} is invalid.
- #{string.inspect} does not represent an instance of #{model_
- #{string.inspect} does not represent an instance of WorkItem
- No object found for `userId: #{user_id.to_s.inspect}`
AI-assisted analysis of gitlabhq/gitlabhq@55ee20384a (2026-08-21).
Data as JSON: /api/errors/abcc5a674b4176ae.
Report an issue: GitHub.