Skip to content

fix(cli-v2): adjust file paths in fern config migrate to be root-relative#15817

Merged
iamnamananand996 merged 4 commits into
mainfrom
devin/1778427163-fix-migrate-file-paths
May 14, 2026
Merged

fix(cli-v2): adjust file paths in fern config migrate to be root-relative#15817
iamnamananand996 merged 4 commits into
mainfrom
devin/1778427163-fix-migrate-file-paths

Conversation

@iamnamananand996
Copy link
Copy Markdown
Contributor

@iamnamananand996 iamnamananand996 commented May 10, 2026

Description

Linear ticket: Closes FER-10462

fern config migrate produced wrong file path references in the generated fern.yml for single-API projects. Paths from generators.yml (relative to the fern/ directory) were not re-rooted to be relative to the project root where fern.yml is written. The docs $ref pointer also used ./docs.yml instead of ./fern/docs.yml.

Changes Made

  • Added projectRoot parameter to convertSingleApi, convertMultiApi, and migrateDocsYml so paths are computed dynamically via path.relative(projectRoot, fernDir) — no hardcoded directory names
  • Unified path adjustment into rebaseSpecPaths(specs, sourcePrefix) / rebasePath(filePath, sourcePrefix) / computeRelativePosixPath(from, to), replacing the duplicated adjustSpecPaths/adjustSpecPathsForSingleApi functions
  • Both single-API and multi-API code paths now use the same dynamic path rebasing logic
  • Updated Migrator.ts to pass this.cwd as projectRoot to all path-adjusting functions
  • Updated README.md generator (if applicable) — N/A

Example

Given generators.yml in fern/ with openapi: ../external/universal-api-v1.yaml and overrides: ./openapi-overrides.yml:

  • Before: paths copied verbatim → ../external/... and ./openapi-overrides.yml (wrong from project root)
  • After: paths rebased → ./external/universal-api-v1.yaml and ./fern/openapi-overrides.yml (correct)

Testing

  • Unit tests added/updated — all 690 tests pass
  • New test for single-API path adjustment with ../ paths
  • Updated existing test assertions for correct path expectations
  • pnpm format clean

Link to Devin session: https://app.devin.ai/sessions/294b273b9cb84d6a82171f9c2e67a4a8
Requested by: @iamnamananand996

…tive

Paths from generators.yml (relative to fern/) were not being adjusted
when written to the root fern.yml. This caused 'file does not exist'
errors for openapi specs, overrides, and docs.yml references.

- Add adjustSpecPathsForSingleApi to re-root single-API spec paths
- Fix docs  to use ./fern/docs.yml instead of ./docs.yml
- Normalize paths with .. segments (e.g. ../external/ -> ./external/)
- Add test for single-API path adjustment
- Update existing test assertions

Resolves FER-10462
@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

@iamnamananand996 iamnamananand996 marked this pull request as ready for review May 10, 2026 15:57
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.

iamnamananand996 and others added 3 commits May 10, 2026 16:04
Add handling for when sourcePrefix is an empty string so rebased spec paths are returned as "./<file>" rather than producing an extra slash or malformed path. Also add a unit test ensuring spec paths remain correct when fernDir equals projectRoot (empty sourcePrefix). This prevents incorrect './ /file' or double-slash paths for specs and overrides.
@iamnamananand996 iamnamananand996 merged commit e6ac0d9 into main May 14, 2026
59 checks passed
@iamnamananand996 iamnamananand996 deleted the devin/1778427163-fix-migrate-file-paths branch May 14, 2026 14:48
fern-support added a commit that referenced this pull request May 14, 2026
…lative (#15817)

* fix(cli-v2): adjust file paths in fern config migrate to be root-relative

Paths from generators.yml (relative to fern/) were not being adjusted
when written to the root fern.yml. This caused 'file does not exist'
errors for openapi specs, overrides, and docs.yml references.

- Add adjustSpecPathsForSingleApi to re-root single-API spec paths
- Fix docs  to use ./fern/docs.yml instead of ./docs.yml
- Normalize paths with .. segments (e.g. ../external/ -> ./external/)
- Add test for single-API path adjustment
- Update existing test assertions

Resolves FER-10462

* refactor: compute migration paths dynamically using path.relative instead of hardcoding FERN_DIRECTORY

* fix: resolve biome lint errors (import ordering and unused import)

* Handle empty sourcePrefix in rebasePath

Add handling for when sourcePrefix is an empty string so rebased spec paths are returned as "./<file>" rather than producing an extra slash or malformed path. Also add a unit test ensuring spec paths remain correct when fernDir equals projectRoot (empty sourcePrefix). This prevents incorrect './ /file' or double-slash paths for specs and overrides.

---------

Co-authored-by: Naman Anand <info@buildwithfern.com>
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