You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[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
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 accountapi_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
Root cause: in src/lib/credentials.ts (parseCredentials), the header pattern /^\[([^\]]+)\]$/ is anchored. When a header doesn't match, currentEntry keeps pointing at the previous section.
Fix (PR ready):
Accept an optional trailing #/; comment after a header (/^\[([^\]]+)\]\s*(?:[#;].*)?$/).
Make any other line starting with [ reset the current section, so keys under a header the parser can't read never land in another profile.
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!
Activity
neromtoobad commentedon Oct 23, 2026
Could a maintainer add the
needs-triage(andhackathon) 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!