Skip to content

Fix cannot return null error on VulnerabilityStateTransitionType.author

What does this MR do and why?

The author_id column is nullable in the database.

This causes VulnerabilityStateTransitionType.author to throw a GraphQL error when the value is null.

How to set up and validate locally

  • Nullify the author on a local Vulnerability::StateTransition in the rails console, and obtain the vulnerability_id:
vst = Vulnerabilities::StateTransition.last
vst.update(author_id: nil)
puts vst.vulnerability_id
  • Run the following query in in your gdk /-/graphql-explorer, replacing vulnerability_id
query
{
  vulnerability(id: "gid://gitlab/Vulnerability/<vulnerability_id>")
  {
    id
    title
    stateTransitions {
      nodes {
        author {
          id
        }
      }
    }
  }
}

Prior to this change the above query will return an error "Cannot return null for non-nullable field VulnerabilityStateTransitionType.author"

After the change the query will run successfully and return a null author.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #412596 (closed)

Edited by Malcolm Locke

Merge request reports

Loading