Skip to content

[Hackathon] fix(credentials): a profile header with a trailing comment moves its keys into the profile above, and the next write loses a key #702

Closed as not planned

Description

@neromtoobad

Verified against (commit SHA or released version)

commit a18d37c

Discord Username / User ID

neromtoobad

What does this improvement do?

parseCredentials only recognises a section header that is exactly [name]. A hand-edited credentials file with a comment on the header line, such as:

[default]
api_key = sk-user-DEFAULTKEY

[prod]  # production account
api_key = sk-user-PRODKEY

parses as { default: { apiKey: 'sk-user-PRODKEY' } }. The unreadable header line is skipped, but the parser is still inside [default], so prod's key overwrites the default one. As a result:

  • auth status and every default-profile command silently authenticate as the prod account.
  • --profile prod fails with "No credentials are stored for profile prod" (exit 3).
  • The next command that writes the file (for example setup --profile staging …) saves that parsed state. The original default key is lost, and the [prod] section disappears.

Repro at a18d37c: node -e "import('./dist/lib/credentials.js').then(m => console.log(m.parseCredentials('[default]\napi_key = A\n[prod] # c\napi_key = B\n')))" prints { default: { apiKey: 'B' } }. The same happens with a ; comment.

Details / implementation notes

Confirmations

  • I have searched existing issues and this is not a duplicate.
  • I have provided my Discord identity above for reward coordination.

Activity

  1. neromtoobad commented on Oct 29, 2026

    @neromtoobad
    Author

    /assign

  2. testsprite-hob commented on Oct 29, 2026

    @testsprite-hob

    Thanks for the interest, @neromtoobad! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it accepted once it is). Feel free to check back, or ping us on Discord if it's been quiet.

  3. fyZhang66 commented on Oct 30, 2026

    @fyZhang66
    Contributor

    Thanks @neromtoobad, the parse is as you describe, but the credentials file is written and owned by the CLI and hand-added comments aren't something we support (same answer as #495), and we have no report of this in practice. Closing this and #705 as not planned.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    hackathonCLI hackathon submissions

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions