fix(modules): clarify Run simulate API auth errors#1655
Conversation
When Simulate hits Aptos API gateway 401/429 responses, show actionable copy and link to Settings instead of raw SDK error text. Fixes #1654 Co-authored-by: Cursor <cursoragent@cursor.com>
✅ Deploy Preview for aptos-explorer ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Bundle ReportChanges will increase total bundle size by 2.87kB (0.03%) ⬆️. This is within the configured threshold ✅ Detailed changes
Affected Assets, Files, and Routes:view changes for bundle: aptos-explorer-server-esmAssets Changed:
Files in
view changes for bundle: aptos-explorer-client-esmAssets Changed:
Files in
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1655 +/- ##
==========================================
+ Coverage 31.97% 32.08% +0.11%
==========================================
Files 182 183 +1
Lines 8561 8579 +18
Branches 3215 3226 +11
==========================================
+ Hits 2737 2753 +16
- Misses 5820 5822 +2
Partials 4 4 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
| {simulationError.suggestSettings && ( | ||
| <Typography | ||
| variant="body2" | ||
| sx={{ | ||
| color: "text.secondary", | ||
| mt: 1, | ||
| }} | ||
| > | ||
| Check <Link to="/settings">API keys in Settings</Link>. | ||
| An invalid or expired mainnet override replaces the | ||
| built-in key used for simulation. | ||
| </Typography> | ||
| )} |
There was a problem hiding this comment.
This only makes sense if the API key is overridden, maybe we should check that state?

Context
On explorer.aptoslabs.com (mainnet), the account Modules → Run tab Simulate button can fail with HTTP 401 from the Aptos fullnode:
This is an API Gateway authentication / per-IP policy response—not a Move VM simulation failure.
Why Write can still work: Simulate uses Explorer’s browser
sdkV2Client(getApiKey()→Authorization: Bearer …onapi.mainnet.aptoslabs.com). Write uses the connected wallet’ssignAndSubmitTransactionand the wallet’s own mainnet RPC, so wallet submit can succeed while Simulate fails.Common causes: invalid Settings → API Keys mainnet override (replaces the built-in key), missing
Authorizationon the simulate request, or gateway per-IP rules for the application client ID.Covers FEAT-MODULES-001 (Run sub-tab).
What changed
formatAptosApiErrorForDisplay()(app/utils/aptosApiErrorMessage.ts) to detect HTTP 401 / 429 (and related gateway copy) and return user-facing text that distinguishes API access failures from Move execution errors.Contract.tsx): on simulate failure, show the friendly message and, when appropriate, a link to Settings → API keys.Links
Fixes #1654
Fixes DVR-161
Test plan
pnpm test --run app/utils/aptosApiErrorMessage.test.tspnpm lint