Improve pipelines setup command with validation retry loops#12401
Improve pipelines setup command with validation retry loops#12401jonesphillip merged 4 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 39170a7 The changes in this PR will be included in the next version bump. 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 |
|
Claude finished @jonesphillip's task —— View job Changeset Review
✅ All changesets look good The changeset
The changeset description is well-written and addresses the earlier feedback from @ascorbic - it now provides sufficient detail about the changes including validation retry prompts, simple mode, automatic bucket creation, and automatic Data Catalog enablement, along with the user benefit. |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
e0b4a0c to
c446aa5
Compare
ascorbic
left a comment
There was a problem hiding this comment.
Just a couple of small things raised in the automated reviews. Then it should be good to go.
…tion and remove redundant tests
…s, and expand changese
123c5bf to
39170a7
Compare
|
|
||
| if (created.stream) { | ||
| await displayUsageExamples(created.stream, config, args); | ||
| await setupSQLTransformationWithValidation(config, setupConfig); |
There was a problem hiding this comment.
🔴 Orphaned stream and sink without guidance when SQL setup throws during pipeline creation retry
When pipeline creation fails and the user opts to retry with different SQL, setupSQLTransformationWithValidation is called at packages/wrangler/src/pipelines/cli/setup.ts:1229. If the user then fails SQL validation and declines the retry within that function (or cancels SQL file loading, etc.), a UserError is thrown that propagates out of createPipelineIfNeeded unhandled — bypassing the helpful guidance messages at lines 1216-1225 that tell the user about their already-created stream and sink resources.
Root Cause and Impact
The setupSQLTransformationWithValidation call at line 1229 is not wrapped in a try/catch. Any UserError it throws (e.g., "SQL validation failed and setup cannot continue..." from line 1047, "SQL file loading cancelled" from loadSqlFromFile, or "SQL query cannot be empty" from line 996) propagates directly up to the handler's catch block at line 365, which simply re-throws it.
This means the user sees only the error message (e.g., "SQL validation failed...") but never sees the critical guidance:
You can create the pipeline later with: wrangler pipelines create
Your stream "..._stream" and sink "..._sink" are ready.
The stream and sink have already been created at this point (by reviewAndCreateStreamSink), so the user is left with orphaned resources and no instructions on how to complete the setup.
Impact: Users who hit SQL issues during a pipeline creation retry will have orphaned cloud resources (stream and sink) with no guidance on how to finish setting up their pipeline or clean up.
Prompt for agents
In the createPipelineIfNeeded function (packages/wrangler/src/pipelines/cli/setup.ts), wrap the call to setupSQLTransformationWithValidation at line 1229 in a try/catch block. When it throws (e.g. UserError from SQL validation failure or cancellation), display the same helpful guidance that is shown when the user explicitly declines retry (lines 1216-1225), informing them that their stream and sink were created successfully and that they can create the pipeline later with wrangler pipelines create. Then return gracefully instead of letting the error propagate. For example:
try {
await setupSQLTransformationWithValidation(config, setupConfig);
} catch (sqlError) {
logger.log(chalk.dim("\n Stream and sink were created, but pipeline creation failed."));
logger.log(chalk.dim("\n You can create the pipeline later with: wrangler pipelines create"));
logger.log(chalk.dim(` Your stream "${setupConfig.streamName}" and sink "${setupConfig.sinkName}" are ready.`));
return;
}
Was this helpful? React with 👍 or 👎 to provide feedback.
Add validation retry loops to pipelines setup command:
In addition to new tests, conducted these manual tests: