Skip to content

PIPE-647: Resolve pipeline resources by name#13960

Merged
cmackenzie1 merged 1 commit into
mainfrom
pipelines-name-resolution
May 26, 2026
Merged

PIPE-647: Resolve pipeline resources by name#13960
cmackenzie1 merged 1 commit into
mainfrom
pipelines-name-resolution

Conversation

@cmackenzie1

@cmackenzie1 cmackenzie1 commented May 18, 2026

Copy link
Copy Markdown
Contributor

Background

Users hitting wrangler pipelines ... commands with resource names were seeing API 1015/1016 errors because the CLI only attempted ID lookups.

Why

The pipelines API resolves names server-side, but the CLI needs to retry with a listing fallback whenever the API returns known "not found" status codes. This preserves compatibility for pipelines, streams, and sinks that users identify by name.

What changed

  • added a shared resolver that retries on 404/1000/1015/1016 responses
  • switched get/delete commands to resolve IDs via the fallback helper
  • extended list client methods and tests to cover name pagination cases

Fixes https://jira.cfdata.org/browse/PIPE-647

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented May 18, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: a4b1ab5

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk May 18, 2026
@workers-devprod workers-devprod requested review from a team and jamesopstad and removed request for a team May 18, 2026 19:16
@workers-devprod

workers-devprod commented May 18, 2026

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • ✅ @cloudflare/wrangler
Show detailed file reviewers

@cmackenzie1 cmackenzie1 marked this pull request as draft May 18, 2026 19:17
@github-actions

github-actions Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@ask-bonk

ask-bonk Bot commented May 18, 2026

Copy link
Copy Markdown
Contributor

The list.ts just passes page and per_page directly -- no auto-pagination. The test mock handler (without { once: true }) can handle multiple requests, which is needed since the mock now simulates pagination, but the list command itself only makes one request per invocation. The test assertions changed from count === 1 to count > 0 and dataCount === 1, which accounts for the mock potentially serving the pagination-capable handler. This is fine.

After thorough review, I've found one real logic issue:

Bug in get.ts: When getPipeline throws an error that is NOT an APIError at all (e.g., a TypeError, network error, etc.), or is an APIError with a code other than 1000/2 -- the code correctly re-throws. However, when it IS code 1000/2 and findPipelineByName itself throws an unexpected error (e.g., network failure during the list call), that error propagates from line 46 and the original error from getPipeline is lost. This is actually fine -- the secondary failure is more relevant.

Actually, I realize there's no real bug here. The whole flow is correct.

Let me look one more time at a subtlety -- in get.ts, error is used on line 63 (throw error), but if findPipelineByName successfully returns a pipeline (line 47-48), we fall through to line 62 where !pipeline is false, so we skip the throw. But error is a const in the catch scope, so TypeScript is happy. And it's never used if pipeline was found. Good.

Let me check one more edge case in the test expectations -- the "resolves pipeline by name across multiple pages" test:

The test sets perPageLimit: 1 and creates 3 pipelines, but only target_pipeline should match the name filter. The mock filters by name, so filteredPipelines has length 1. With perPage: 1, first page returns the single match, second page returns empty, so listRequest.count === 2. The test asserts expect(listRequest.count).toBe(2). This seems correct given the mock behavior.

Wait actually -- the mock does client-side filtering by name. If expectedName is "target_pipeline", then filteredPipelines will be [{id: "pipeline_target", name: "target_pipeline", ...}] (length 1). With perPageLimit: 1, perPage = min(requestedPerPage, 1) = 1. Page 1: startIndex = 0, returns 1 item. Page 2: startIndex = 1, returns 0 items. So indeed 2 requests, 1 with data. The assertion listRequest.count === 2 is correct.

After this thorough review, I believe the code is well-structured and correct. The patterns are consistent, error handling is proper, and tests cover the key scenarios. There are no logic bugs, security issues, or backward compatibility problems.

LGTM

github run

@pkg-pr-new

pkg-pr-new Bot commented May 18, 2026

Copy link
Copy Markdown
create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@13960

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@13960

miniflare

npm i https://pkg.pr.new/miniflare@13960

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@13960

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@13960

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@13960

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@13960

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@13960

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@13960

wrangler

npm i https://pkg.pr.new/wrangler@13960

commit: a4b1ab5

devin-ai-integration[bot]

This comment was marked as resolved.

@cmackenzie1 cmackenzie1 force-pushed the pipelines-name-resolution branch from f9783cd to 4830e42 Compare May 20, 2026 22:15
Background
----------
Users hitting `wrangler pipelines ...` commands with resource names were
seeing API 1015/1016 errors because the CLI only attempted ID lookups.

Why
----
The pipelines API resolves names server-side, but the CLI needs to retry
with a listing fallback whenever the API returns known "not found"
status codes. This preserves compatibility for pipelines, streams, and
sinks that users identify by name.

What changed
------------
* added a shared resolver that retries on 404/1000/1015/1016 responses
* switched get/delete commands to resolve IDs via the fallback helper
* extended list client methods and tests to cover name pagination cases

See https://jira.cfdata.org/browse/PIPE-647

PIPE-647: Handle hex-like pipeline resource names
@cmackenzie1 cmackenzie1 force-pushed the pipelines-name-resolution branch from 4830e42 to a4b1ab5 Compare May 20, 2026 22:28
@cmackenzie1 cmackenzie1 self-assigned this May 21, 2026
@cmackenzie1 cmackenzie1 marked this pull request as ready for review May 21, 2026 17:09
@petebacondarwin

Copy link
Copy Markdown
Contributor

I think this will need a docs update with the new options...

@cmackenzie1

Copy link
Copy Markdown
Contributor Author

I think this will need a docs update with the new options...

you mean bonk won't do this for me 😢. Docs update incoming...

@cmackenzie1

Copy link
Copy Markdown
Contributor Author

@petebacondarwin corresponding docs PR cloudflare/cloudflare-docs#31025

@petebacondarwin petebacondarwin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thanks

@workers-devprod workers-devprod left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codeowners reviews satisfied

@github-project-automation github-project-automation Bot moved this from Untriaged to Approved in workers-sdk May 22, 2026
@cmackenzie1 cmackenzie1 merged commit 39d8717 into main May 26, 2026
63 of 65 checks passed
@cmackenzie1 cmackenzie1 deleted the pipelines-name-resolution branch May 26, 2026 20:19
@github-project-automation github-project-automation Bot moved this from Approved to Done in workers-sdk May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants