Fix error when calling GQL ciConfig endpoint with include:component
What does this MR do and why?
Currently, when you make a ciConfig
GraphQl request as below, it returns an internal server error response. This happens only when the provided config content contains include:component
. The problem is due to requesting the includes -> extra
field (a serialized hash).
For components, the extra
field contains a Project object (introduced in !147378 (diffs)). However, serializing an object (especially Project) is forbidden, so we return an error.
query getCiConfig($projectPath: ID!, $content: String!) {
ciConfig(projectPath: $projectPath, content: $content) {
includes {
location
type
extra
contextProject
}
}
}
This MR fixes this problem with the following:
- Moves the component project and other attributes out of
extra
and into a newcomponent
field of the external filemetadata
. This new field is not exposed in the API and therefore does not raise the serialization error. - It also removes the redundant
component_
prefix since it is now sufficiently described by thecomponent
key.
Resolves #455376.
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
Screenshots or screen recordings
Before: Error response | After: No error |
---|---|
How to set up and validate locally
- Create a new blank Project.
- In that Project, create a new component named
my_component.yml
. - Go to
http://gdk.test:3000/-/graphql-explorer
and test the following GraphQl query. Update the project and component paths as necessary for your local environment. The config content should include the new component you made in Step 2.
query getCiConfig($projectPath: ID!, $content: String!) {
ciConfig(projectPath: $projectPath, content: $content) {
includes {
location
type
extra
contextProject
}
}
}
{
"content": "include:\n - component: gdk.test:3000/group-b/test-project-1/my_component@main\n",
"projectPath": "group-b/test-project-1"
}
- Observe that the response is as expected and does not return an error.
Related to #455376
Edited by Leaminn Ma