fix(cli): make docs-validator rule init failures honor configured severity#15853
Conversation
When a docs-validator rule throws an exception during its asynchronous create() step, the validator emits a 'Rule "X" failed to initialize' violation. Previously this violation was hardcoded to severity "fatal", which meant configuring a rule at 'warn' in docs.yml (e.g. 'missing-redirects: warn') had no effect on init-time failures and would still fail 'fern check' with exit code 1. This change makes those init failures respect the user's configured severity. It also fixes the rendered message when a non-Error value is thrown — previously surfaced as '[object Object]' — by serializing plain objects to JSON, and adds a try/catch around DocsDefinitionResolver.resolve() inside the missing-redirects rule so transient resolution errors degrade to a warning instead of a fatal. Signed-off-by: cade <info@buildwithfern.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
Signed-off-by: cade <info@buildwithfern.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
…directs Signed-off-by: cade <info@buildwithfern.com> Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
|
@claude review once |
There was a problem hiding this comment.
Code review is billed via overage credits. To resume reviews, an organization admin can raise the monthly limit at claude.ai/admin-settings/claude-code.
Once credits are available, comment @claude review on this pull request to trigger a review.
Description
Linear ticket: Refs
When a docs-validator rule throws an exception during its asynchronous
create()step, the validator emits aRule "X" failed to initializeviolation. Previously this violation was hardcoded toseverity: "fatal", which meant configuring a rule atwarnindocs.ymlhad no effect on init-time failures —fern checkwould still exit 1.Reported by a customer (NVIDIA-NeMo/Gym) whose CI was failing on:
…despite having
check.rules.missing-redirects: warnconfigured indocs.yml. The rule itself already had defensivemakeSkipVisitorpaths that emitwarningseverity for things like FDR fetch failures, but an exception thrown fromDocsDefinitionResolver.resolve()bypassed those and bubbled out ofcreate(), hitting the hardcoded-fatal branch invalidateDocsWorkspace.ts.The
[object Object]portion was a separate bug:String(error)was being called on a thrown non-Errorvalue with no usefultoString.Changes Made
validateDocsWorkspace.ts: whenrule.create()throws, look up the rule's configured severity (severityOverrides) and use it for the resulting violation.warn→warning,error→error, no override →fatal(preserves existing behavior for any rule without an explicit override).formatInitError.ts(new): format unknown thrown values into a readable message. Plain objects are serialized to JSON; circular / empty objects fall through toObject.prototype.toString.call(...). Eliminates[object Object]in user-facing messages.rules/missing-redirects/missing-redirects.ts: wrapDocsDefinitionResolver.resolve()+ the v1→latest navigation migration in atry/catchthat returns a newmakeSkipVisitor({ type: "resolve-failed" })(rendered as awarning). This is a defense-in-depth fix: even on a CLI version without the framework-level severity change above, the missing-redirects rule no longer crashescheckwhen local navigation fails to resolve.__test__/formatInitError.test.ts(new): unit tests covering Error, string, plain object, empty object, circular object,null, andundefinedinputs.packages/cli/cli/changes/unreleased/.Testing
pnpm test --filter @fern-api/docs-validator→ 151/151 passing, 6 new)fern checkagainst the customer's repo (NVIDIA-NeMo/Gym PR [openapi linter] requirex-server-namefor servers #1299, commitbad8dead2); rule degrades gracefully without modifying their docs.yml.pnpm lint:biome --fixandpnpm format:fixclean.Link to Devin session: https://app.devin.ai/sessions/bd3a58d7c2c44de0b1f23ea520709888
Requested by: @fern-support