Skip to content

fix(cli): make docs-validator rule init failures honor configured severity#15853

Merged
fern-support merged 3 commits into
mainfrom
devin/1778604888-missing-redirects-soft-fail
May 14, 2026
Merged

fix(cli): make docs-validator rule init failures honor configured severity#15853
fern-support merged 3 commits into
mainfrom
devin/1778604888-missing-redirects-soft-fail

Conversation

@fern-support
Copy link
Copy Markdown
Collaborator

Description

Linear ticket: Refs

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 had no effect on init-time failures — fern check would still exit 1.

Reported by a customer (NVIDIA-NeMo/Gym) whose CI was failing on:

[docs] 1 error
    [error]
        path: docs.yml
        issue: Rule "missing-redirects" failed to initialize: [object Object]

…despite having check.rules.missing-redirects: warn configured in docs.yml. The rule itself already had defensive makeSkipVisitor paths that emit warning severity for things like FDR fetch failures, but an exception thrown from DocsDefinitionResolver.resolve() bypassed those and bubbled out of create(), hitting the hardcoded-fatal branch in validateDocsWorkspace.ts.

The [object Object] portion was a separate bug: String(error) was being called on a thrown non-Error value with no useful toString.

Changes Made

  • validateDocsWorkspace.ts: when rule.create() throws, look up the rule's configured severity (severityOverrides) and use it for the resulting violation. warnwarning, errorerror, 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 to Object.prototype.toString.call(...). Eliminates [object Object] in user-facing messages.
  • rules/missing-redirects/missing-redirects.ts: wrap DocsDefinitionResolver.resolve() + the v1→latest navigation migration in a try/catch that returns a new makeSkipVisitor({ type: "resolve-failed" }) (rendered as a warning). 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 crashes check when local navigation fails to resolve.
  • __test__/formatInitError.test.ts (new): unit tests covering Error, string, plain object, empty object, circular object, null, and undefined inputs.
  • Changelog entry under packages/cli/cli/changes/unreleased/.
  • Updated README.md generator (if applicable)

Testing

  • Unit tests added/updated (pnpm test --filter @fern-api/docs-validator → 151/151 passing, 6 new)
  • Manual testing completed — built the dev CLI and ran fern check against the customer's repo (NVIDIA-NeMo/Gym PR [openapi linter] require x-server-name for servers #1299, commit bad8dead2); rule degrades gracefully without modifying their docs.yml.
  • pnpm lint:biome --fix and pnpm format:fix clean.

Link to Devin session: https://app.devin.ai/sessions/bd3a58d7c2c44de0b1f23ea520709888
Requested by: @fern-support

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-integration
Copy link
Copy Markdown
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@devin-ai-integration devin-ai-integration Bot changed the title fix(docs-validator): make rule init failures honor configured severity fix(cli): make docs-validator rule init failures honor configured severity May 12, 2026
fern-support and others added 2 commits May 12, 2026 17:16
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>
@fern-support
Copy link
Copy Markdown
Collaborator Author

@claude review once

Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Code review skipped — your organization's overage spend limit has been reached.

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.

@fern-support fern-support merged commit e2a5426 into main May 14, 2026
60 checks passed
@fern-support fern-support deleted the devin/1778604888-missing-redirects-soft-fail branch May 14, 2026 22:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants