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 #702
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.
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.
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.
Activity
neromtoobad commentedon Oct 29, 2026
/assign
testsprite-hob commentedon Oct 29, 2026
Thanks for the interest, @neromtoobad! This issue hasn't been accepted for implementation yet — see the triage comment (a maintainer will label it
acceptedonce it is). Feel free to check back, or ping us on Discord if it's been quiet.fyZhang66 commentedon Oct 30, 2026
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.