Skip to content

[Hackathon] fix(project): project auto-auth --disable cannot be used alone — required --method/--inject force fabricated config into the disable request #379

Closed

Description

@OceanRanger

Verified against (commit SHA or released version)

commit 988c035 (v0.14.0, current main)

Discord Username / User ID

ocean_ranger — preferred contact: PR comments or GitHub (Discord available but not actively monitored)

What does this improvement do?

testsprite project auto-auth <id> --disable is documented as the off-switch (--disable — "turn auto-auth off (keeps stored config)"), but it can never be used that way:

$ testsprite project auto-auth p1 --disable
error: required option '--method <method>' not specified        # exit 5

--method and --inject are declared unconditionally .requiredOption() (src/commands/project.ts:1669-1670), so the only way to reach the disable path is to invent values:

$ testsprite project auto-auth p1 --disable --method password --inject bearer
projectId p1
enabled   false

The invented values are not just accepted — they are sent in the disable request body. runAutoAuth builds the body unconditionally as { enabled, method, inject } with no disable branch, so the "off" switch overwrites the stored policy's method/inject with whatever the user was forced to make up.

Three defects in one flow:

  1. The documented off-switch is unusable (exit 5 following the help text).
  2. The user must fabricate configuration unrelated to disabling.
  3. Those fabricated values reach the wire (PUT /projects/p1/auto-auth body carries enabled:false plus the made-up method/inject), so disabling can silently rewrite the stored policy's shape.

Details / implementation notes

Steps to reproduce

# 1. Documented usage fails:
testsprite project auto-auth <project-id> --disable
#   -> error: required option '--method <method>' not specified (exit 5)

# 2. Forced workaround sends the fabricated values:
testsprite project auto-auth <project-id> --disable --method password --inject bearer --debug
#   -> PUT /api/cli/v1/projects/<id>/auto-auth  body: {"enabled":false,"method":"password","inject":"bearer",...}

(Verified against a local endpoint with --debug; any HTTP-dumping proxy shows the same body.)

Suggested approach

  • Make --method / --inject plain options; in runAutoAuth, require them only when enabling (opts.disable !== true), with the error naming the --disable alternative.
  • Enum-validate them only when present.
  • Build the body as { enabled } plus method/inject only when provided, so a disable never persists fabricated config. (--disable with explicitly provided values still forwards them, for callers that want to pin the stored shape.)

Happy to implement with tests once confirmed; will claim with /assign. One concern per PR: the disable path only — no other flag semantics change. The staged fix keeps the enable path byte-identical (same body, same validation errors except the new actionable message when --method/--inject are missing).

Side note: the --disable sends enabled:false unit test in project.test.ts currently has to pass fabricated method/inject to reach the disable path — the test itself mirrors this bug.

Confirmations

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

Activity

  1. OceanRanger commented on Oct 22, 2026

    @OceanRanger
    ContributorAuthor

    /assign

  2. testsprite-hob commented on Oct 22, 2026

    @testsprite-hob

    Thanks for the interest, @OceanRanger! 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 22, 2026

    @fyZhang66
    Contributor

    Thanks @OceanRanger, confirmed: --disable can't be used alone. The fix also needs a backend change (the API requires method/inject even when disabling), so we'll fix it on our side. Closing this one.

  4. added
    hackathon
    on Oct 22, 2026
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

    hackathon

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions