Skip to content

tidy-api/oauthflow: one body per resolution, not one per caller - #240

Merged
dinstein merged 3 commits into
mainfrom
tidy-oauth
Aug 7, 2026
Merged

tidy-api/oauthflow: one body per resolution, not one per caller#240
dinstein merged 3 commits into
mainfrom
tidy-oauth

Conversation

@dinstein

@dinstein dinstein commented Aug 7, 2026

Copy link
Copy Markdown
Owner

Nightly tidy over api and internal/oauthflow: three resolution/prologue bodies that existed twice, where the second copy is what a future third caller would be copied from.

  • 1. api: one body for the two data-directory flavours (dataDirNamed, mirroring internal/platform)
  • 2. api: one place that fills in a StartOptions (resolve)
  • 3. internal/oauthflow: postCredential — the SSRF screen is not a step a credential POST can skip

dinstein and others added 3 commits August 7, 2026 18:28
dataDir and devDataDir were the same twenty-line platform switch differing
in one constant — the directory name. windowsDataDir already took that
name as a parameter, so only the Unix branches were duplicated, and
internal/platform (the resolver this package's comments promise to stay
byte-identical to) has shared its own for the same stated reason: a rule
applied to one copy and not the other is how the dev and release
directories come to sit in different parents.

dataDirNamed is that switch once, and the two entry points name their
constant. The AGENTHUB_DATA_DIR lookup stays ahead of every branch, where
both copies already had it — which is where this still differs from
internal/platform, and the comment now says so.

make ci green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
DialOrStart and StartSupervised take the same StartOptions and each
opened with the same twenty lines of defaulting: socket path, daemon
binary, run directory, deadline, poll interval. StartOptions documents
those defaults on the fields themselves ("0 = 10s", "0 = 100ms", "" = dir
of SocketPath), so two copies meant that documentation could become true
of one entry point and false of the other, and the two ways of bringing a
daemon up would then look for it in different places.

StartOptions.resolve is that sequence once. DaemonArgs is the one thing
the two genuinely disagree about — `daemon start`, plus `--foreground`
for a supervised child — so it is the one thing passed in.

make ci green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
postForm and postJSON each spelled out the same prologue for a
credential-bearing POST: parse the endpoint, run checkURL, build the
request, set Content-Type / Accept / User-Agent, add the caller's headers,
Do, classify a transport failure. checkURL is the SSRF screen, so a third
credential POST written by copying either one could lose it and nothing
would say so.

postCredential is that prologue once. It stops at the response rather
than also refusing a 3xx: both callers refuse it, but with different
errors — a token exchange redacts the Location it reports, because that
header can echo back the credential just sent, while a registration does
not read it — and a parameter for that would make the zero-redirect rule
read as a caller's choice.

One ordering change comes with it: postJSON now marshals its payload
before parsing the endpoint, so an unmarshalable payload beats a bad
endpoint. Both are programmer errors and the payloads are in-package
structs, but it is a change rather than a rename.

make ci green.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dinstein
dinstein merged commit 0f61cf7 into main Aug 7, 2026
3 checks passed
@dinstein
dinstein deleted the tidy-oauth branch August 7, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant