Skip to content

fix(branch): keep database_password out of --json output - #303

Open
Abhishek-B-R wants to merge 2 commits into
InsForge:mainfrom
Abhishek-B-R:fix/branch-output-database-password
Open

Abhishek-B-R wants to merge 2 commits into
InsForge:mainfrom
Abhishek-B-R:fix/branch-output-database-password

Conversation

@Abhishek-B-R

@Abhishek-B-R Abhishek-B-R commented Sep 24, 2026 •

Copy link
Copy Markdown

Problem

branch reset <name> --json prints the branch object exactly as the API returns it, which includes the plaintext database_password. branch create --json and branch list --json print branch objects the same way, so the same value can show up there too. Command output ends up in scrollback, CI logs and captured run artifacts, none of which treat it as secret.

Fix

A small redactBranch helper in src/commands/branch/redact.ts returns a copy of the branch without database_password, and branch reset, branch create and branch list run their JSON output through it. The password is omitted rather than masked, following the first option in the issue: nothing in the CLI reads it from these responses, so there is no masked form anyone needs. The human readable output never printed the branch object, so it is unchanged. branch switch and branch delete only print ids.

This removes a field from the --json output of those three commands. I checked InsForge/agent-skills and it doesn't mention database_password, so no skill update is needed.

Tests

One new test each in reset.test.ts, create.test.ts and list.test.ts: the mocked API returns a branch with a database_password (two branches in the list test), and the test checks the JSON output still has the branch but not the password. All three fail on main.

After rebasing on main (b9c28c3):

  • npx vitest run: 829 passed, 14 skipped (826 on main, plus the 3 new ones)
  • npx eslint src/: clean
  • npm run build: succeeds
  • npx tsc --noEmit: the same 12 errors that exist on main, none new

Closes #235


Summary by cubic

Stops branch reset, branch create, and branch list from leaking the branch's plaintext database_password in --json output. The branch object is now passed through a redactBranch helper that omits the field before printing, since command output ends up in CI logs and scrollback.

Breaking changes

  • --json output of those three commands no longer includes database_password; human-readable output is unchanged and branch switch/branch delete only print ids.

Written for commit 10bea78. Summary will update on new commits.

Review in cubic

Summary by CodeRabbit

  • Bug Fixes
    • Branch creation, listing, and reset JSON output no longer includes database passwords. Other branch details, such as branch names and IDs, remain available.

branch reset, branch create and branch list printed the branch object
straight from the API, including the plaintext database_password. Strip it
before printing.
@agent-zhang-beihai

Copy link
Copy Markdown
Contributor

Thanks for the PR, @Abhishek-B-R! This links #235, but that issue isn't assigned to anyone yet. Our workflow is claim the issue first, then submit the PR. It'll still be reviewed — to keep ownership clear, comment on the issue that you'd like it assigned to you.

@agent-zhang-beihai agent-zhang-beihai Bot added the needs-claim PR work started without being assigned the issue — claim the issue first label Sep 24, 2026
@coderabbitai

coderabbitai Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 3b951199-3bb4-4ee4-94b4-bbec468559bd

📥 Commits

Reviewing files that changed from the base of the PR and between b9c28c3 and cc0c83b.

📒 Files selected for processing (7)
  • src/commands/branch/create.test.ts
  • src/commands/branch/create.ts
  • src/commands/branch/list.test.ts
  • src/commands/branch/list.ts
  • src/commands/branch/redact.ts
  • src/commands/branch/reset.test.ts
  • src/commands/branch/reset.ts

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

Branch create, list, and reset commands now remove database_password from branch objects in JSON output. Tests verify that the field is omitted and other branch data remains present.

Changes

Branch JSON redaction

Layer / File(s) Summary
Redact branch JSON output
src/commands/branch/redact.ts, src/commands/branch/create.ts, src/commands/branch/list.ts, src/commands/branch/reset.ts, src/commands/branch/create.test.ts, src/commands/branch/list.test.ts, src/commands/branch/reset.test.ts
redactBranch removes database_password from a copied branch object. The create, list, and reset commands apply it to JSON output. Tests verify that the field is omitted.

Priority: ⬆️ High

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: High

Suggested reviewers: fermionic-lyu

Merge Risk: ⚪ Minimal · up to cc0c8

Branch JSON output omits the database password, and no issue requiring a change before merge was identified.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 4 functions across 7 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Issue #235 requires that branch reset JSON output does not expose plaintext database_password. The PR adds redactBranch, removes that field from a shallow copy, and applies it to branch reset, `…
Out of Scope Changes check ✅ Passed The changes stay within issue #235. The shared redaction helper, command integrations, and focused tests directly support removal of database_password from branch JSON output. No unrelated behavior …
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: excluding database_password from branch command JSON output.
  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR

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

A rabbit checks the branch JSON stream,
No password spills into the beam.
Create and list and reset all,
Keep the secret from the scroll.
The bunny hops through tests with cheer,
And finds the branch id still is here.

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

@greptile-apps

greptile-apps Bot commented Sep 24, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

The PR appears safe to merge.

Summary

The PR omits database_password from branch create, list, and reset JSON output while leaving human-readable output unchanged. Since the previous review, the list test was expanded to verify redaction for two branches.

Reviews (2) · Last reviewed commit: "test(branch): assert every branch in --j..."

@cubic-dev-ai cubic-dev-ai Bot 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.

All reported issues were addressed across 7 files

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread src/commands/branch/list.test.ts
@Abhishek-B-R

Copy link
Copy Markdown
Author

I'd like to take this one, could you assign it to me? I've already opened #303 with a fix (adds a redactBranch helper that strips database_password from the --json output of branch reset, create, and list). Happy to keep ownership clear.

@agent-zhang-beihai agent-zhang-beihai Bot removed the needs-claim PR work started without being assigned the issue — claim the issue first label Sep 25, 2026
@Abhishek-B-R

Copy link
Copy Markdown
Author

@tonychang04 friendly bump: the needs-claim label is cleared and the cubic/greptile findings are addressed (greptile 5/5). The CI workflow is waiting on maintainer approval to run, and after that it only needs a review. Happy to adjust anything if the approach doesn't fit.

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.

branch reset prints the branch database_password in its JSON output

2 participants