Propagate errors when probing for generated schemas - #303
Conversation
Four checks for a generated schemas directory discarded their error and treated the failure as "no schemas". An unreadable or otherwise failing schemas directory therefore produced a silently degraded result rather than an error: - generatePythonFiles and generateGoFiles scaffold a function without the local schema dependency, so the generated code fails to compile later for a reason unrelated to the real fault. - generateGoTemplatingFiles omits the model index path. - pythonBuilder.buildVenv builds an image without the project's python schemas. afero.DirExists and afero.Exists already report a missing directory as (false, nil), so a non-nil error here is a genuine I/O or permission fault and is worth surfacing. Signed-off-by: Steven Borrelli <steve@borrelli.org> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughSchema filesystem checks now propagate errors with contextual messages during function file generation and Python virtual-environment setup. ChangesSchema error propagation
Estimated code review effort: 1 (Trivial) | ~5 minutes Merge Risk: ⚪ Minimal · up to The change makes schema-directory I/O failures surface immediately instead of silently generating incomplete artifacts. No actionable merge-blocking risk remains after normal checks and review. Suggested reviewers: Important Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional. ❌ Failed checks (1 error)
✅ Passed checks (5 passed)
Full details: Breaking ChangesExplanation
Full details: Feature Gate RequirementExplanation PASS. The pull request introduces no new experimental feature. The verified commit changes only
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. Comment |
Integration fix. crossplane#304 adds a cacheDir parameter to baseImageForArch; crossplane#170 adds a TypeScript builder that calls it. The branches merge cleanly because they touch different files, but the result does not compile without this. Whichever PR merges second upstream needs this one line. Also update the testing notes: crossplane#302 and crossplane#303 have merged, so they now arrive through main rather than as merges here. Signed-off-by: Steven Borrelli <steve@borrelli.org> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The opening still said the branch merges four open PRs when only two remain open. Reword it so the count does not go stale again, mark the --no-default-mrap check as testing something that now lives in main, and add a short section recording what has already landed. Signed-off-by: Steven Borrelli <steve@borrelli.org> Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Description of your changes
Four probes for a generated schemas directory discarded their error and treated the failure as "no schemas". An unreadable schemas directory therefore produced a silently degraded result instead of an error:
generatePythonFilesgenerateGoFilesdev.crossplane.io/modelsreplace directivegenerateGoTemplatingFilespythonBuilder.buildVenvIn each case the user sees the real fault much later and in a misleading form — generated code that doesn't compile, or a function image missing its models — with nothing pointing at the schemas directory.
afero.DirExistsandafero.Existsalready report a missing directory as(false, nil), so a non-nil error here is a genuine I/O or permission fault and is worth surfacing rather than discarding.Found while reviewing feedback on #170, which flags the same pattern in the TypeScript paths that PR introduces. Those instances live in code that only exists on that branch, so they're fixed there; this PR covers the pre-existing ones on
main.Deliberately not changed
internal/schemas/generator/python.go:769uses the sameif exists, _ := afero.Exists(...)shape when creating__init__.pyfiles, but the error is not truly lost there: a failing probe falls through toafero.WriteFile, which reports its own wrapped error. Happy to include it if a reviewer would rather have it consistent.I have:
./nix.sh flake checkto ensure this PR is ready for review.Added or updated unit tests.Linked a PR or a docs tracking issue to document this change.Addedbackport release-x.ylabels to auto-backport this PR.Need help with this checklist? See the cheat sheet.
🤖 Generated with Claude Code