Skip to content

Fix error when calling GQL ciConfig endpoint with include:component

Leaminn Ma requested to merge fix-included-component-file-attrs into master

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 new component field of the external file metadata. 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 the component 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
Screenshot_2024-05-14_at_6.35.41_PM Screenshot_2024-05-14_at_6.37.27_PM

How to set up and validate locally

  1. Create a new blank Project.
  2. In that Project, create a new component named my_component.yml.
  3. 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"
}
  1. Observe that the response is as expected and does not return an error.
Screenshot Screenshot_2024-05-14_at_6.37.27_PM

Related to #455376

Edited by Leaminn Ma

Merge request reports