Skip to content

feat: EU region URL validation + unit tests (continuation of #88)#96

Open
Abdeltoto wants to merge 4 commits into
smartsheet-platform:mainfrom
Abdeltoto:feat/url-utils-tests
Open

feat: EU region URL validation + unit tests (continuation of #88)#96
Abdeltoto wants to merge 4 commits into
smartsheet-platform:mainfrom
Abdeltoto:feat/url-utils-tests

Conversation

@Abdeltoto

Copy link
Copy Markdown

👋 PR #2 of 3 from a Smartsheet power user (see #95 for context).

This PR is complementary to #88 by @is-isaac — it cherry-picks his 3 commits (attribution preserved as Sisyphus <clio-agent@sisyphuslabs.ai>, the original commit author) and adds the missing piece blocking the merge: unit tests for url-utils.ts.

Why a separate PR rather than commenting on #88

PR #88 has been open since February with no reviewer activity, and several users in #87 / #92 are blocked by the same EU auth bug. Re-bundling the code with tests (resolved against current main) gives reviewers a single clean PR to merge. If you'd rather pull just the test commit onto #88 directly, please feel free — happy either way.

What's in here

  • Commits 1-3 (cherry-pick of fix: EU region frontend authentication #88 by @is-isaac, conflicts with current main already resolved):
    • feat: add URL utility with EU/US region detection
    • fix: add EU region validation to URL-based tools
    • docs: add EU region endpoint to config examples
  • Commit 4 (new): test(utils): add Jest coverage for url-utils — 33 unit tests:
    • parseSmartsheetUrl: US/EU detection, query strings, trailing path segments, case-insensitive hostnames, malformed URLs returning null, URL-constructor fallback path.
    • detectApiRegion: canonical US/EU endpoints, generic .eu hostnames, malformed input fallback, case-insensitive matching.
    • regionLabel + validateRegionMatch: matching and mismatched pairs in both directions; asserts the diagnostic mentions both regions, suggests the corrected SMARTSHEET_ENDPOINT, and explains a region-specific token is required.

Why this matters

Region mismatches between SMARTSHEET_ENDPOINT and the URL passed to get_sheet_by_url/search_in_sheet_by_url/what_am_i_assigned_to_by_sheet_url produce silent 401s today. After this change:

  • EU users get an actionable error telling them exactly which env var to update.
  • Same diagnostic for US users who accidentally point at api.smartsheet.eu.
  • The region is exposed as api.region so downstream tools can do their own validation.

Test plan

  • npm test72/72 passed (3 suites, +33 tests from this PR)
  • npm run typecheck → clean
  • Verified the diagnostic copy renders correctly for both eu→us and us→eu mismatches
  • Tested the fallback path with malformed URLs (URL constructor throws)

Closes the testing gap on #88. Refs #87, #92 (EU auth reports).

sisyphus-dev-ai and others added 4 commits April 18, 2026 02:02
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
URL-based tools (get_sheet_by_url, search_in_sheet_by_url, what_am_i_assigned_to_by_sheet_url) now detect whether the frontend URL points to the EU or US region and validate it against the configured SMARTSHEET_ENDPOINT. A region mismatch returns a clear, actionable error instead of an opaque auth failure.

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-opencode)

Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
…ectApiRegion, validateRegionMatch)

Adds 33 unit tests covering the three exported helpers introduced for EU region support:

- parseSmartsheetUrl: US/EU detection, query strings, trailing path segments, case-insensitive hostnames, malformed URLs (return null), URL constructor fallback path.

- detectApiRegion: canonical US/EU endpoints, generic .eu hostnames, malformed input fallback, case-insensitive matching.

- regionLabel + validateRegionMatch: matching and mismatched pairs in both directions, asserts the diagnostic mentions both regions, the corrected SMARTSHEET_ENDPOINT, and that a region-specific token is required.

All tests pass; total suite is 72/72.

Made-with: Cursor
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.

2 participants