Skip to content

improvement(credentials): actionable Shopify admin-token rejection message#5891

Merged
waleedlatif1 merged 1 commit into
stagingfrom
worktree-shopify-admin-token-audit
Jul 23, 2026
Merged

improvement(credentials): actionable Shopify admin-token rejection message#5891
waleedlatif1 merged 1 commit into
stagingfrom
worktree-shopify-admin-token-audit

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • When Shopify rejects a custom-app Admin API token, the connect modal now tells the user what to check instead of a vague "double-check it in Shopify". Root cause of the field reports (verified against prod logs + a live Shopify probe) is a real 401 from Shopify — the user pasted the API key/secret key instead of the shpat_ Admin API access token, or a token bound to a different store.
  • Added an optional per-provider invalidCredentialsHelp override on the token service-account descriptor; set it for Shopify to name the exact fix (copy the shpat_ Admin API access token from the app's "API credentials" tab, confirm the app is installed, token must match the store domain).
  • Moved the error-code → message mapping out of the shared connect modal into the descriptor module (getTokenServiceAccountErrorMessage) so provider-specific copy is inherited from the definition rather than hard-coded in the modal. The modal now just unwraps the API error shape and delegates.
  • No change to validation logic — it was already correct.

Type of Change

  • Improvement

Testing

  • Added unit tests for the mapper (Shopify override, generic fallback, every error code, unknown/absent code). All 30 credential-area tests pass.
  • Verified the validator's real behavior against live Shopify: nonexistent store → 404 → site_not_found; real store + bad token → 401 → invalid_credentials.
  • Typecheck clean on changed files; Biome + check:api-validation pass.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Jul 23, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 23, 2026 6:07pm

Request Review

@cursor

cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
User-facing copy and a small refactor only; credential verification behavior is unchanged.

Overview
Centralizes token service-account connect-modal error copy in the descriptor module and adds Shopify-specific guidance when verification returns invalid_credentials.

The shared connect modal no longer embeds error-code mapping; it passes the API error.code into getTokenServiceAccountErrorMessage, which uses each provider’s tokenNoun, serviceLabel, and an optional invalidCredentialsHelp override. Shopify’s descriptor sets that override to call out the common mistake (API key/secret vs shpat_ Admin API token, store domain, revocation).

Unit tests cover the mapper for Shopify override, generic fallback, known codes, and unknown/missing codes.

Reviewed by Cursor Bugbot for commit b61c36a. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

The PR centralizes token service-account error messaging and adds actionable Shopify-specific invalid-token guidance.

  • Adds an optional provider-level invalidCredentialsHelp override.
  • Delegates connect-modal error mapping to the descriptor module.
  • Adds unit coverage for provider overrides, known error codes, and fallback behavior.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

Important Files Changed

Filename Overview
apps/sim/lib/credentials/token-service-accounts/descriptors.ts Adds provider-specific invalid-credentials guidance and centralizes verification error-code mapping.
apps/sim/app/workspace/[workspaceId]/integrations/components/connect-service-account-modal/token-service-account-modal.tsx Replaces local error-message mapping with the shared descriptor-based mapper.
apps/sim/lib/credentials/token-service-accounts/descriptors.test.ts Covers Shopify-specific guidance, generic provider behavior, known codes, and fallback cases.

Reviews (2): Last reviewed commit: "improvement(credentials): actionable Sho..." | Re-trigger Greptile

Comment thread apps/sim/lib/credentials/token-service-accounts/descriptors.ts Outdated
…ssage

Shopify custom-app token verification faithfully surfaces a real 401 from
Shopify, but the generic 'double-check it in Shopify' copy didn't tell users
what to check. The #1 real cause is pasting the wrong secret (API key / API
secret key) instead of the shpat_ Admin API access token, or using a token
bound to a different store.

- Add an optional per-provider invalidCredentialsHelp override on the token
  service-account descriptor; set it for Shopify to name the exact fix.
- Move the error-code to message mapping out of the shared connect modal into
  the descriptor module (getTokenServiceAccountErrorMessage) so provider copy
  is inherited from the definition rather than hard-coded in the modal.
- Add unit tests for the mapper (override, fallback, all codes).
@waleedlatif1
waleedlatif1 force-pushed the worktree-shopify-admin-token-audit branch from b2602ed to b61c36a Compare July 23, 2026 18:07
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b61c36a. Configure here.

@waleedlatif1
waleedlatif1 merged commit 44749b8 into staging Jul 23, 2026
15 checks passed
@waleedlatif1
waleedlatif1 deleted the worktree-shopify-admin-token-audit branch July 23, 2026 18:10
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