Repository navigation
[wrangler] Print temporary account notices to stderr - #16068
Conversation
🦋 Changeset detectedLatest commit: a2c88ae The changes in this PR will be included in the next version bump. This PR includes changesets to release 5 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
LGTM |
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
@cloudflare/containers-shared
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/runtime-types
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
e4e6f91 to
d2f9d0c
Compare
dario-piotrowicz
left a comment
There was a problem hiding this comment.
Thanks for the PR @edevil 🙏
I find that renaming the statusLogger to logger during the flow makes the whole thing really difficult to read, could we keep a consistent name for the variable?
statusLogger also seems unnecessarily unclear to me, what about stdErrLogger or warnLevelLogger or something to this extend to more clearly show what it's doing? (this applies to the type as well of course)
Also additionally, I do wonder if it's better to convert the log to be in a warn level or on a debug one, like in: #16029 I think both approaches have their own merits. But in particular I think that the debug one is pretty nice in the fact that the terminal text actually presented to the user is all json parsable, so the user can, if they want actually copy-paste the JSON-parsable text. 🤔 |
The terms notice, proof-of-work message and "Temporary account ready" claim details were logged to stdout, corrupting JSON and raw values that commands write there, and disappearing when --json commands lowered the log level. Add a temporaryAccountLogger option to workers-auth for these notices and route it to stderr in Wrangler. Keep WRANGLER_LOG=none in d1 execute --json, which previously raised it to "error" and would now let the claim details through.
d2f9d0c to
a2c88ae
Compare
|
Thanks @dario-piotrowicz . I've renamed it to On debug vs stderr, these messages cannot be hidden, the claim URL is the only way someone can claim the account, and we need to show the ToS, so I have to leave them in stderr. |
workers-devprod
left a comment
There was a problem hiding this comment.
Codeowners reviews satisfied
With
--temporary, three messages were logged to stdout through the injected logger: the terms notice (non-interactive mode), "Solving proof-of-work challenge…", and the "Temporary account ready" block with the claim URL. The last one is printed on every run, including when a cached account is reused. As a result:kv namespace list --temporaryno longer printed valid JSON, andkv key get --temporaryput the banner in front of the value. Once [wrangler] Support temporary event accounts in R2 and Containers commands #16036 lands, the same would apply tor2 object get --pipeand the--jsonmodes of R2 and Containers commands."error"for--json, such asd1 execute --json, dropped the banner entirely, so the participant never saw the claim URL.This PR:
workers-auth: adds an optional
AuthContext.temporaryAccountLogger(typeTemporaryAccountLogger = Pick<Logger, "log">). It receives the three temporary-account messages, is passed into the flow's temporary context for the proof-of-work message, and defaults tologger. ThecfCLI's behavior is unchanged.OAuthFlowTemporaryContext.prompt's doc already said the notice belongs on stderr.wrangler: passes
temporaryAccountLogger: { log: (...args) => logger.console("error", ...args) }. This writes the text unformatted (no▲ [WARNING]), stays visible when a command sets the level to"error", still respects--log-level none, and runs the logger's spinner hooks. These messages are no longer written to the debug log file, which also keeps the claim token out of it.d1 execute:
--jsonraised the log level to"error"even when it was"none". Status messages are logged at the"error"level, so this would have printed the claim details despiteWRANGLER_LOG=none. It now keeps"none".Behavior change: scripts that read the claim URL from stdout now need stderr (
2>&1). This is called out in the changeset.--temporaryis a hidden flag; the output stream change is described in the changeset.