Skip to content

fix: don't error remote database status command if database was not enabled yet to provide more meaningful output#8218

Open
pieh wants to merge 7 commits intomainfrom
fix/database-status-branch-not-yet-created
Open

fix: don't error remote database status command if database was not enabled yet to provide more meaningful output#8218
pieh wants to merge 7 commits intomainfrom
fix/database-status-branch-not-yet-created

Conversation

@pieh
Copy link
Copy Markdown
Contributor

@pieh pieh commented Apr 28, 2026

🎉 Thanks for submitting a pull request! 🎉

Summary


For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style guide and
    passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

A picture of a cute animal (not mandatory, but encouraged)

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 28, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cd940c5b-e2fe-4a44-8d01-c24d9eaa58e2

📥 Commits

Reviewing files that changed from the base of the PR and between 4ea63a0 and 6b0ffd0.

📒 Files selected for processing (1)
  • src/commands/database/db-status.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/commands/database/db-status.ts

📝 Walkthrough

Summary by CodeRabbit

Bug Fixes

  • Fixed database status command's branch checking when Netlify Database is disabled—eliminated unnecessary remote requests and ensures correct status reporting.

Walkthrough

The PR changes the --branch path in the database status command so remote branch connection-string and remote applied-migrations are fetched only if the site reports a configured database (siteHasDatabase true). If the site has no database, the code avoids remote requests by using an empty applied-migrations result and proceeds with status computation. A unit test is added to verify that when Netlify Database is disabled (siteDatabase: null) no remote endpoints are called, no DB connection is made, and logs indicate the database is not enabled with zero applied/pending migrations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: preventing errors in the remote database status command when the database is not yet enabled, and providing more meaningful output instead.
Description check ✅ Passed The description is related to the changeset, referencing the database status command issue, though it primarily contains a contributor checklist rather than detailed change motivation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/database-status-branch-not-yet-created

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.

❤️ Share
Review rate limit: 5/8 reviews remaining, refill in 20 minutes and 11 seconds.

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 28, 2026

📊 Benchmark results

Comparing with 89ce39f

  • Dependency count: 1,061 (no change)
  • Package size: 355 MB (no change)
  • Number of ts-expect-error directives: 355 (no change)

@pieh pieh marked this pull request as ready for review April 28, 2026 08:24
@pieh pieh requested a review from a team as a code owner April 28, 2026 08:24
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/commands/database/db-status.ts`:
- Around line 418-421: Remove the explanatory inline comments and make the
intent explicit in code: replace the commented assignment with a clearly named
noop function (e.g., const noopFetchApplied = async () => []; ) and assign
fetchApplied = noopFetchApplied (or directly use fetchApplied = async () => []),
removing the comment lines entirely so the code reads self-documentingly; update
any nearby references to use the new symbol if introduced.

In `@tests/unit/commands/database/db-status.test.ts`:
- Line 773: The test uses an invalid matcher by expecting a Promise<void> to
"resolves.not.toThrow()"; update the assertion to check the resolved value
instead: call statusDb with createMockCommand() and replace the matcher with
"resolves.toBeUndefined()" so the promise resolution for statusDb({ branch:
'feature-x' }, createMockCommand()) is asserted correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 635136a6-44a3-4f75-8109-fbb7cacda462

📥 Commits

Reviewing files that changed from the base of the PR and between 3deb552 and ae8c1fc.

📒 Files selected for processing (2)
  • src/commands/database/db-status.ts
  • tests/unit/commands/database/db-status.test.ts

Comment thread src/commands/database/db-status.ts Outdated
Comment thread tests/unit/commands/database/db-status.test.ts Outdated
kathmbeck
kathmbeck previously approved these changes Apr 28, 2026
database-proxy might be setting connection string and provision on demand, tricking into thinking
that database is already provisioned
@pieh pieh force-pushed the fix/database-status-branch-not-yet-created branch from df3f153 to 4e6fa3e Compare April 29, 2026 18:37
connectionString = await fetchBranchConnectionString({ siteId, accessToken, basePath }, branch)
fetchApplied = remoteAppliedMigrations({ siteId, accessToken, basePath, branch })
branchLabel = branch
if (siteHasDatabase) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This explicitly is not using enabled check, because when used with @netlify/database-proxy and NETLIFY_DB_URL (IIRC) it is reported as true even if database is not actually created yet, so fetchBranchConnectionString that is hitting an API would return failure.

The enabled logic might need some more thinking about desired interaction with @netlify/database-proxy, but this seems a bit out of scope for this change.

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.

2 participants