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 #651

Open

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 23, 2026

    @neromtoobad
    Author

    Could a maintainer add the needs-triage (and hackathon) label here? I opened this through the gh CLI, and contributors without repo access can't add labels (GitHub returns a permissions error). A fix with tests is ready to go once this is triaged. Thanks!

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions