Skip to content

fix(codegen): don't require runtime settings to generate the GraphQL schema#199

Open
sudoBrandino wants to merge 1 commit into
rivenmedia:mainfrom
sudoBrandino:pr/codegen-schema-env
Open

fix(codegen): don't require runtime settings to generate the GraphQL schema#199
sudoBrandino wants to merge 1 commit into
rivenmedia:mainfrom
sudoBrandino:pr/codegen-schema-env

Conversation

@sudoBrandino
Copy link
Copy Markdown
Contributor

@sudoBrandino sudoBrandino commented Jun 2, 2026

codegen:gql-schema imports the resolver graph to emit schema.graphql. Importing it eagerly constructs the core Settings object, which parses RIVEN_SETTING__* and throws a ZodError when databaseUrl / redisUrl / vfsMountPath aren't set.

In practice the schema only generates on a turbo cache hit — any change that invalidates the codegen cache without runtime settings in the env (a clean CI checkout, a cold Docker build) fails the build.

Schema generation only needs the resolver types, not real settings values, so this sets harmless build-time placeholders before importing the graph (real values still come from the runtime env_file), with the imports made dynamic so they apply first. No runtime behaviour change.

Summary by CodeRabbit

  • Bug Fixes

    • Fixed potential schema generation failures that occurred when required environment variables were absent. The build process now initializes gracefully with sensible defaults.
  • Chores

    • Refactored schema generation script to use dynamic imports for improved build process flexibility and reliability.

The gql-schema codegen imports the resolver graph, which constructs the
core Settings object and throws without RIVEN_SETTING__* values. Set
build-time placeholders so codegen runs without runtime settings, fixing
the Docker build and verify jobs on a cold turbo cache.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: d9de56b0-76c7-4d4e-aed5-e0daa627a591

📥 Commits

Reviewing files that changed from the base of the PR and between 5fe8262 and 9852d14.

📒 Files selected for processing (1)
  • apps/riven/scripts/generate-gql-schema.ts

📝 Walkthrough

Walkthrough

The schema generation script now uses dynamic imports and initializes placeholder environment variables for required settings (databaseUrl, redisUrl, vfsMountPath) before importing resolvers. This prevents resolver graph construction from failing when environment variables are absent during schema generation. The schema output and build call remain unchanged.

Changes

GraphQL Schema Generation Robustness

Layer / File(s) Summary
Environment variable initialization and dynamic resolver imports
apps/riven/scripts/generate-gql-schema.ts
Placeholder environment variables are initialized using ??= operators for databaseUrl, redisUrl, and vfsMountPath before dynamic resolver import to prevent resolver graph eager construction from throwing; schema emission call remains functionally unchanged.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 When env vars hide and resolvers cry,
We set some defaults way up high,
Dynamic imports come to play,
So schemas build both night and day! 📜✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: fixing schema generation to not require runtime settings. It directly addresses the core problem the PR solves.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

ESLint install failed. For unrecoverable errors, disable the tool in CodeRabbit configuration.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Jun 2, 2026

Coverage Report for Riven

Status Category Percentage Covered / Total
🔴 Lines 66.37%
⬆️ +3.73%
1773 / 2671
🔴 Statements 66.4%
⬆️ +3.69%
1791 / 2697
🔴 Functions 67.3%
⬆️ +4.94%
385 / 572
🔴 Branches 55.63%
⬆️ +4.11%
800 / 1438
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Affected Files
apps/riven/lib/message-queue/flows/process-media-item/process-media-item.processor.ts 44.26%
⬆️ +3.28%
23.8%
🟰 ±0%
100%
🟰 ±0%
44.26%
⬆️ +3.28%
57-58, 71-98, 119, 149-228, 232
apps/riven/lib/message-queue/flows/request-content-service/request-content-service.processor.ts 22.44%
🟰 ±0%
10.71%
⬆️ +3.57%
33.33%
🟰 ±0%
22.44%
🟰 ±0%
28-32, 74-177
apps/riven/lib/message-queue/sandboxed-jobs/utilities/create-sandboxed-worker.ts 76.92%
⬆️ +7.69%
50%
🟰 ±0%
66.66%
⬆️ +33.33%
76.92%
⬆️ +7.69%
74-78
Generated in workflow #372 for commit 9852d14 by the Vitest Coverage Report Action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant