Skip to content

fix(vtex): surface real cause of "typo in url or port" errors#423

Merged
viniciusventura29 merged 1 commit into
mainfrom
viniciusventura29/fix-vtex-tools-url-error
May 6, 2026
Merged

fix(vtex): surface real cause of "typo in url or port" errors#423
viniciusventura29 merged 1 commit into
mainfrom
viniciusventura29/fix-vtex-tools-url-error

Conversation

@viniciusventura29
Copy link
Copy Markdown
Collaborator

@viniciusventura29 viniciusventura29 commented May 6, 2026

Summary

  • When state.accountName arrived empty, the URL became https://.vtexcommercestable.com.br and Bun rejected it with the cryptic "Was there a typo in the url or port?" — across many tools.
  • Adds a fail-fast assertValidCredentials check that throws a descriptive error naming the missing field, used in the generated-tool adapter and both custom tools (reorder-collection, update-product-specifications).
  • Enriches SDK errors with credential-source context ([tool=… account=… accountSource=state|env|missing …]) and logs the resolved baseUrl + mesh-context shape on every tool call so the inconsistent state-propagation path can be diagnosed in production.

Test plan

  • bun run check (vtex) — passes
  • bun test (vtex) — 77 pass, 0 fail
  • Reproduced locally: calling a tool without VTEX_ACCOUNT_NAME now returns the descriptive fail-fast error instead of the Bun "typo in url or port" message
  • Verified through deco.host UI tunnel: when state is properly injected, [VTEX] tool=… mesh-context-shape: {hasToken:true, stateAccountNamePresent:true, …} is logged and the call succeeds

🤖 Generated with Claude Code


Summary by cubic

Fail-fast validation for VTEX tools to prevent invalid base URLs and replace Bun’s “Was there a typo in the url or port?” with a clear error when accountName is missing. Adds source-aware error context and lightweight logging to make config issues easy to diagnose.

  • Bug Fixes
    • Added assertValidCredentials in the tool adapter and custom tools to throw a clear error when accountName is missing (avoids https://.vtexcommercestable.com.br).
    • Updated resolveCredentials to pull from state or env and return per-field sources; warns when accountName is missing.
    • Enriched thrown errors with [tool=… account=… accountSource=…] context.
    • Logged baseUrl creation and mesh-context shape on each call to trace state propagation.

Written for commit 2052d4e. Summary will update on new commits.

When state.accountName arrived empty the URL became
"https://.vtexcommercestable.com.br" and Bun rejected it with a cryptic
"Was there a typo in the url or port?". This swaps that for a fail-fast
assertion that names the missing field, attaches credential-source
context to SDK errors, and logs the resolved baseUrl + mesh-context
shape so the inconsistent state-propagation path can be diagnosed.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@viniciusventura29 viniciusventura29 merged commit f19bab7 into main May 6, 2026
2 checks passed
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