Skip to content

Make name field in ScanExecutionPolicyCommit mutation mandatory

Why are we doing this work

We added name field in ScanExecutionPolicyCommit graphql mutation which was made as non-mandatory field to make it backward compatible with frontend. After #342695 (closed) is finished, we need to make it required: true.

Relevant links

Non-functional requirements

  • Documentation:
  • Feature flag:
  • Performance:
  • Testing:

Implementation plan

  • backend Add required: true to name argument in ee/app/graphql/mutations/security_policy/commit_scan_execution_policy.rb:

       argument :name, GraphQL::Types::String,
                required: true,
                description: 'Name of the policy. If the name is null, the `name` field from `policy_yaml` is used.'

Verification steps

  1. Go to /-/graphql-explorer
  2. Type a query like:
mutation updatePolicy($input: ScanExecutionPolicyCommitInput!) {
  scanExecutionPolicyCommit(input: $input) {
    branch
    errors
  }
}

with an input like

{
  "input": {
    "fullPath": "testscanresultpolicies/license-approval-policies-test",
    "operationMode": "REPLACE",
    "policyYaml": ""
  }
}
  1. Check the error message

Screenshot_2023-04-24_at_6.23.58_PM

Edited by Marcos Rocha