Add fail_on_cache_miss parameter to CI config variables GraphQL resolver
What does this MR do and why?
This MR adds backend support for a fail_on_cache_miss
parameter to the CI config variables GraphQL resolver. This allows clients to explicitly request an error when the reactive cache is not ready, instead of receiving a null
response.
This is part of the work to improve error handling in the CI variables GraphQL API, split from !207773 to separate backend and frontend changes.
Problem
Currently, when the ciConfigVariables
GraphQL field is queried and the reactive cache is not ready, it returns null
without any indication of why the data is unavailable. This makes it difficult for clients to distinguish between:
- Cache not ready (temporary state)
- No variables exist (valid empty state)
- An actual error occurred
Solution
Add an optional failOnCacheMiss
boolean argument (defaults to false
for backward compatibility) to the ciConfigVariables
field. When set to true
:
- If the cache is not ready, raise a
CacheNotReadyError
- The error is caught and converted to a GraphQL error with a clear message
- Clients can handle this error appropriately (e.g., retry, show loading state)
When false
(default), behavior remains unchanged - returns null
when cache is not ready.
References
- Parent MR: !207773
How to set up and validate locally
-
Start GDK and navigate to GraphiQL (
/-/graphql-explorer
) -
Test default behavior (cache miss returns null):
query { project(fullPath: "your-project-path") { ciConfigVariables(ref: "main") { key value description } } }
Expected: Returns
null
if cache not ready -
Test with
failOnCacheMiss: true
:query { project(fullPath: "your-project-path") { ciConfigVariables(ref: "main", failOnCacheMiss: true) { key value description } } }
Expected: Returns GraphQL error "Failed to retrieve CI/CD variables from cache." if cache not ready
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.