Skip to content

Fix invalid underscore in OpenAPI bin domain names#85

Merged
martyndavies merged 4 commits into
mainfrom
fix/dns-url-issues
May 13, 2026
Merged

Fix invalid underscore in OpenAPI bin domain names#85
martyndavies merged 4 commits into
mainfrom
fix/dns-url-issues

Conversation

@martyndavies
Copy link
Copy Markdown
Contributor

Summary

  • New OpenAPI bins use -oas suffix instead of _oas, producing RFC 1035-compliant subdomains
  • Legacy _oas bins still validate, detect, and invoke correctly (regex + isOasBin accept both)
  • Frontend isOas check in www/pages/bins/[binId].tsx updated so new -oas bins still render OAS-specific UI
  • Yaml side-bin id switched from _YAML_original to -YAML-original for consistency

Why

Subdomains like <id>_oas.api.mockbin.io failed TLS handshake in Java (and other strict) HTTP clients because underscores aren't valid in DNS hostnames:

javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

Test plan

  • npx vitest run — 28/28 pass (18 existing + 10 new)
  • Create new OpenAPI bin via UI, confirm URL has -oas and resolves over HTTPS
  • Hit existing legacy _oas bin, confirm still routes
  • Java client smoke test against new -oas URL

Fixes #67

🤖 Generated with Claude Code

New OpenAPI bins now use `-oas` suffix instead of `_oas` so generated
subdomains comply with RFC 1035. Legacy `_oas` bins still validate and
route correctly via updated regex and `isOasBin` detection. Frontend
OAS detection in `[binId].tsx` accepts both formats so existing UI
still flags new bins.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings May 13, 2026 13:42
@zuplo
Copy link
Copy Markdown

zuplo Bot commented May 13, 2026

The latest build updates on your Zuplo project. Learn more about Zuplo for GitHub ↗︎

Name Status Preview Updated (UTC)
API Gateway ✅ Ready (Inspect) Visit Preview May 13, 2026, 02:08 PM
Developer Portal ✅ Ready (Inspect) Visit Preview May 13, 2026, 02:08 PM

@vercel
Copy link
Copy Markdown

vercel Bot commented May 13, 2026

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

Project Deployment Actions Updated (UTC)
mockbin Ready Ready Preview, Comment May 13, 2026 2:07pm

Request Review

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates OpenAPI bin ID generation and detection to avoid underscores in subdomains (RFC 1035 compliance), while maintaining backwards compatibility for legacy _oas bin IDs.

Changes:

  • Generate new OpenAPI bin IDs with the -oas suffix (instead of _oas) and broaden server-side validation to accept both -oas and legacy _oas.
  • Update OAS bin detection on both backend (isOasBin) and frontend (isOas) to recognize the new -oas format.
  • Add Vitest coverage for bin ID validation and OAS detection.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
www/pages/bins/[binId].tsx Updates frontend OAS detection so OAS-specific UI renders for new -oas bin IDs.
tests/bin-id.test.ts Adds tests for validateBinId and isOasBin covering both -oas and _oas.
modules/utils.ts Extends bin ID regex to accept either -oas or _oas suffix and updates isOasBin accordingly.
modules/handlers.ts Switches OpenAPI bin creation to append -oas and changes YAML side-id naming.

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

Comment thread modules/handlers.ts Outdated
Comment thread modules/utils.ts Outdated
Comment thread www/pages/bins/[binId].tsx Outdated
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- isOasBin and frontend isOas now use endsWith so substring matches
  in the middle of a binId no longer trigger OAS code paths
- Add GET /v1/bins/{binId}/original.yaml handler and route that
  serves the original uploaded YAML, with backward-compatible
  storage key derivation for legacy `_oas` bins
- x-mockbin-original-url now points at the new endpoint so the link
  in the served OpenAPI spec is actually reachable

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
router.query value is string | string[]; endsWith is string-only.
Fixes TS build error introduced in prior commit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@martyndavies martyndavies merged commit 9bd73c3 into main May 13, 2026
9 checks passed
@martyndavies martyndavies deleted the fix/dns-url-issues branch May 13, 2026 14:50
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.

Bug: invalid character in domain in case of OpenAPI Bin creation

3 participants