Skip to content

fix: clearer error when the migrations source has no files - #1405

Open
AlisinaDevelo wants to merge 3 commits into
golang-migrate:masterfrom
AlisinaDevelo:fix-empty-source-error
Open

AlisinaDevelo wants to merge 3 commits into
golang-migrate:masterfrom
AlisinaDevelo:fix-empty-source-error

Conversation

@AlisinaDevelo

Copy link
Copy Markdown

Closes #1314.

An empty or mistyped migrations directory currently fails with first .: file does not exist, which gives no hint about the real cause. This returns a new ErrNoMigrationFiles instead. It still wraps os.ErrNotExist, so existing errors.Is checks keep working.

The same cryptic error came up via Up() and Migrate()/Steps() since they share the code path, so both are covered. Added a test.

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 54.442% (+0.01%) from 54.432% — AlisinaDevelo:fix-empty-source-error into golang-migrate:master

@AlisinaDevelo

Copy link
Copy Markdown
Author

Checking in on the no-migration-files error. It returns a typed error while preserving os.ErrNotExist wrapping, and the Go 1.24 and 1.25 tests and lint checks are green. If there’s a compatibility concern or a preferred error shape, I’m happy to adjust; otherwise I’d appreciate a review.

@AlisinaDevelo

Copy link
Copy Markdown
Author

Hey, just checking in on this one—does the error-shape change need anything else from me before review?

Copilot AI lite review requested due to automatic review settings September 27, 2026 06:10

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

This branch has not been deployed

No deployments
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.

Better error message: "first .: file does not exist"

3 participants