Skip to content

Query declaration error for graphql createPackageProtectionRule

What does this MR do and why?

  • Fixing the error that occurs when including packageProtectionRule in the query declaration of the graphql mutation createsPackageProtectionRule
  • On master, there is currently a bug concerning the (recently added) grapqhl mutation createPackagesProtectionRule. When executing the graphql mutation createPackagesProtectionRule and adding the packageProtectionRule in the query declaration, then we receive an internal server error, see below
  • Adding policy for Packages::Protection::Rule necessary to fix the bug and the new test cases; this missing policy was not needed because the existing test cases did not cover this execution path
  • This MR is a follow-up of the MR Protected packages: GraphQL api for creating pa... (!125915 - merged)

image

🛠 with at Siemens

Screenshots or screen recordings

As explained in the description, this MR allows to declare the query packageProtectionRule in the graphql mutation without getting any errors. The body of the graphql request looks like this:

mutation {
	createPackagesProtectionRule(
		input: {
			projectPath: "flightjs/Flight"
			packageNamePattern: "@flight/flight-10*"
			packageType: NPM
			pushProtectedUpToAccessLevel: MAINTAINER
		}
	) {
		packageProtectionRule {
			packageNamePattern
			packageType
			pushProtectedUpToAccessLevel
		}
		errors
	}
}

image

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable feature flag via rails c
Feature.enable(:packages_protected_packages)
  1. Now, you should be able to send mutation requests with the query declaration packageProtectionRule via the graphql api <= this would have crashed on the branch master 🐛
curl --request POST \
  --url http://gdk.test:3000/api/graphql \
  --header 'Authorization: Bearer ypCa3Dzb23o5nvsixwPA' \
  --header 'Content-Type: application/json' \
  --cookie 'perf_bar_enabled=true; BetterErrors-2.10.1-CSRF-Token=0b882179-5e4a-431b-a420-2be3701cece8' \
  --data '{"query":"mutation {\n\tcreatePackagesProtectionRule(\n\t\tinput: {\n\t\t\tprojectPath: \"flightjs/Flight\"\n\t\t\tpackageNamePattern: \"@flight/flight-10*\"\n\t\t\tpackageType: NPM\n\t\t\tpushProtectedUpToAccessLevel: MAINTAINER\n\t\t}\n\t) {\n\t\tpackageProtectionRule {\n\t\t\tpackageNamePattern\n\t\t\tpackageType\n\t\t\tpushProtectedUpToAccessLevel\n\t\t}\n\t\terrors\n\t}\n}\n"}'

Todos

  • Exlcude the id form this MR

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 #416381 (closed)

Edited by Gerardo Navarro

Merge request reports