Repository navigation
Description
Verified against (commit SHA or released version)
commit 988c035 (v0.14.0)
Discord Username / User ID
outrageous_guava_90469_03877
What does this improvement do?
project auto-auth documents --login-method as POST | PUT and --login-content-type as application/json | application/x-www-form-urlencoded (src/commands/project.ts:1675-1676), but runAutoAuth never validates either value. Whatever string is passed is copied verbatim into the PUT request body (src/commands/project.ts:912-913) — and in --dry-run the command still reports success. The same function does validate its sibling enum flags locally: --method and --inject are checked against AUTO_AUTH_METHODS / AUTO_AUTH_INJECTS (:831-832) and rejected with VALIDATION_ERROR / exit 5 (:884, :887). Only these two sub-flags of the password method slip through — there is no check anywhere for them.
Details / implementation notes
Verified against commit 988c035 (v0.14.0), built from source, Node v24.20.0, Linux x86_64. All runs below are --dry-run, so no network is involved; in live mode the same unchecked values are copied into the PUT body the same way (:912-913).
$ testsprite project auto-auth p1 --dry-run --method password --inject bearer
--login-url https://idp.example.com/login
--login-method DELETE --login-content-type text/plain
projectId p1
enabled true
method password
inject bearer
exit 0 — DELETE is not one of the documented POST | PUT, and text/plain is
not one of the documented content types, yet both are accepted
$ testsprite project auto-auth p1 --dry-run --method password --inject bearer
--login-url https://idp.example.com/login --login-method GET
exit 0 — same for --login-method on its own
$ testsprite project auto-auth p1 --dry-run --method password --inject bearer
--login-url https://idp.example.com/login --login-content-type bogus
exit 0 — same for --login-content-type on its own
Control case, same command and same function: an invalid --method is rejected locally.
$ testsprite project auto-auth p1 --dry-run --method magic --inject bearer
Error: Invalid request.
--method must be one of: password, refresh_token, aws_cognito_refresh
exit 5 — VALIDATION_ERROR
Expected
A --login-method other than POST / PUT, and a --login-content-type other than application/json / application/x-www-form-urlencoded, are rejected locally in runAutoAuth before any request body is built, with the same typed VALIDATION_ERROR / exit 5 that --method and --inject already produce in the same function. The documented valid values are accepted unchanged.
Actual
runAutoAuth validates projectId, --method and --inject up front, then passes opts.loginMethod / opts.loginContentType straight into the request body via maybe(...) (src/commands/project.ts:912-913) with no membership check.
The option help promises closed value sets ("POST | PUT", "application/json | application/x-www-form-urlencoded", :1675-1676), but nothing enforces them, so a typo'd verb or content type is stored server-side as-is and only surfaces later — if at all — as a failing auto-login at test-run time, far from the flag that caused it.
Suggested fix
In runAutoAuth, next to the existing --method / --inject checks, validate the two flags against closed lists mirroring AUTO_AUTH_METHODS / AUTO_AUTH_INJECTS (:831-832), reusing the existing localValidationError helper (:2154, VALIDATION_ERROR / exit 5):
--login-method: one of POST, PUT (only when the flag is provided).
--login-content-type: one of application/json, application/x-www-form-urlencoded (only when the flag is provided).
No behaviour change for valid values or when the flags are omitted. Add cases to the existing runAutoAuth block in src/commands/project.test.ts covering invalid values for each flag (rejected locally, no fetch) plus a valid combination that is still passed through into the PUT body.
Relationship to existing issues
#449 mentions the auto-auth field names only in passing and is about secret echo, not value validation; #379 concerns a different auto-auth flag (--disable). Neither covers --login-method / --login-content-type accepting out-of-set values with exit 0, which is this issue.
Environment
CLI version: 0.14.0 (built from source at 988c035)
Node: v24.20.0
OS: Linux x86_64
Confirmations
- I have searched existing issues and this is not a duplicate.
- I have provided my Discord identity above for reward coordination.
Activity
iamfirst commentedon Oct 19, 2026
/assign
testsprite-hob commentedon Oct 19, 2026
Thanks for the interest, @iamfirst! 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 22, 2026
Thanks @iamfirst. The API already validates both values and rejects anything else (400, exit 5), so nothing invalid is stored; the only difference is where the error comes from. Closing as not planned.