Skip to content

Fetch preview store claim URL from GET request in store info#7929

Open
amcaplan wants to merge 1 commit into
mainfrom
amc-get-claim-url-from-preview-store-get-request
Open

Fetch preview store claim URL from GET request in store info#7929
amcaplan wants to merge 1 commit into
mainfrom
amc-get-claim-url-from-preview-store-get-request

Conversation

@amcaplan

Copy link
Copy Markdown
Contributor

What this does

Following backend shop/world#863938, GET /services/preview-stores/:id now returns claim_url alongside access_url. As a result, shopify store info no longer needs a separate POST .../claim request to obtain the claim ("Save your progress") URL.

This:

  • Makes store info faster — one backend request instead of two (the previous Promise.all of claimPreviewStore + getPreviewStore is now a single getPreviewStore call).
  • Deletes the now-redundant claim code path.

Changes

packages/store/src/cli/services/store/create/preview/client.ts

  • getPreviewStore now reads claim_url from the GET response and returns it as an optional claimUrl. The backend degrades claim_url to null on a BP mint failure, so it's treated as absent rather than an error.
  • Redaction in the GET error path now also covers claim_url.
  • Deleted claimPreviewStore, PreviewStoreClaimRequest, PreviewStoreClaimResponse, RawPreviewStoreClaimResponse, narrowClaimResponse, previewStoreClaimError, and redactPreviewStoreClaimResponse.
  • Renamed previewStoreClaimHeaders to previewStoreAuthenticatedHeaders (now only used by the authenticated GET).

packages/store/src/cli/services/store/info/index.ts

  • fetchPreviewStoreUrls makes a single getPreviewStore call; saveUrl is populated from previewStore.claimUrl when present.

Testsclient.test.ts and index.test.ts: removed dead claim tests, added a claim_url assertion to the GET test, and added coverage for the degraded (null claim URL leads to no saveUrl) path.

Behavior note

Previously, a claim-mint failure threw and aborted store info. Now (matching the backend's intentional design) it degrades gracefully: store info still shows the store and access URL, just without the "Save your progress" link.

No changeset

Preview stores aren't a publicized feature yet, so this change doesn't need a public changelog entry.

Testing

  • 50 tests pass (store/info/index.test.ts + create/preview/client.test.ts)
  • nx run store:type-check clean
  • ESLint clean on all changed files

Following shop/world#863938, GET /services/preview-stores/:id now returns claim_url alongside access_url. store info no longer makes a separate POST .../claim request, reducing backend calls from two to one and removing the now-redundant claim code path.

Assisted-By: devx/77e7fd0b-38f4-44cb-aa92-23fda52bb067
@amcaplan amcaplan requested a review from a team as a code owner June 25, 2026 16:31
Copilot AI review requested due to automatic review settings June 25, 2026 16:31
@github-actions github-actions Bot added the no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users. label Jun 25, 2026

Copilot AI 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.

Pull request overview

Updates the preview-store store info flow to use the claim_url returned by GET /services/preview-stores/:id, removing the now-redundant claim POST request and aligning CLI behavior with the backend’s “degrade gracefully” semantics when claim minting fails.

Changes:

  • Simplifies store info preview-store URL fetching to a single getPreviewStore call and makes saveUrl optional.
  • Extends the preview-store GET client response shape to include optional claimUrl, and removes the legacy claim request path.
  • Updates tests to assert claim_url handling (including the degraded null case) and removes dead claim tests.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
packages/store/src/cli/services/store/info/index.ts Removes claim POST usage; populates optional saveUrl from claim_url returned by GET.
packages/store/src/cli/services/store/info/index.test.ts Updates expectations to match single-request flow; adds coverage for degraded/missing claim URL.
packages/store/src/cli/services/store/create/preview/client.ts Adds claim_url parsing to GET response; removes claim endpoint/client code; renames authenticated headers helper.
packages/store/src/cli/services/store/create/preview/client.test.ts Removes claim endpoint tests; adds GET claim_url assertion and null degradation coverage.
Comments suppressed due to low confidence (1)

packages/store/src/cli/services/store/create/preview/client.ts:255

  • previewStoreGetError returns rawText directly in tryMessage, which can leak sensitive URLs/tokens (and now potentially claim_url) in error output. Use redactPreviewStoreRawText(rawText) before truncating, consistent with the create error path.
function previewStoreGetError(status: number, rawText: string): {message: string; tryMessage?: string} {
  const parsed = parseErrorBody(rawText)
  return {
    message: `Preview store lookup failed with HTTP ${status}.`,
    tryMessage: parsed.message ?? (rawText.length > 0 ? rawText.slice(0, 1000) : 'No response body returned.'),

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

headers: previewStoreAuthenticatedHeaders(getOrCreateCliInstanceId(options.storage), request.adminApiToken),
})

const rawText = await response.text()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog This PR doesn't include a changeset entry. Is an internal only change not relevant to end users.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants