Skip to content

Conversation

Copilot
Copy link

@Copilot Copilot AI commented Oct 11, 2025

Problem

OpenAPI bins were being created with _oas suffix, generating invalid domain names like https://12345678_oas.api.mockbin.io/ when using wildcard subdomains. This violates RFC 1035 DNS hostname standards, which prohibit underscores in domain names, causing TLS handshake failures in Java applications and other strict HTTP clients:

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

Solution

Replace underscores with hyphens in OpenAPI bin IDs while maintaining full backward compatibility:

  • New OpenAPI bins: Use -oas suffix (DNS compliant)
  • Legacy bins: Continue supporting _oas suffix for existing bins
  • All functionality preserved: Validation, detection, and URL generation work for both formats

Changes

Core Logic Updates

  • modules/handlers.ts: Changed bin ID generation from binId += "_oas" to binId += "-oas"
  • modules/utils.ts: Updated regex pattern to accept both [-_]oas formats
  • modules/utils.ts: Enhanced isOasBin() to detect both underscore and hyphen variants
  • modules/handlers.ts: Updated YAML file handling to use consistent hyphen format

Test Coverage

Added comprehensive test suite covering:

  • DNS hostname validation for new format
  • Backward compatibility with legacy format
  • Bin ID validation for both formats
  • OpenAPI bin detection logic

Impact

Before: https://12345678901234567890123456789012_oas.api.mockbin.io/ ❌ (Invalid DNS)
After: https://12345678901234567890123456789012-oas.api.mockbin.io/ ✅ (RFC 1035 compliant)

  • ✅ Resolves TLS handshake failures in Java and other strict HTTP clients
  • ✅ New bins are fully DNS compliant (RFC 1035)
  • ✅ Zero breaking changes - existing bins continue working
  • ✅ All tests passing (28/28 including 10 new tests)

This fix ensures OpenAPI bins work seamlessly with all HTTP clients while maintaining complete backward compatibility.

Original prompt

This section details on the original issue you should resolve

<issue_title>Bug: invalid character in domain in case of OpenAPI Bin creation</issue_title>
<issue_description>Hi!

I have created a few mockbins via the new "Create an OpenAPI Bin" functionality and the tool always generated this URL format:
https://<unique_identifier>_oas.api.mockbin.io/

When attempting to make an HTTPS request to a URL via a simple Java application, the request fails with the following exception:
Caused by: javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure

It seems that the root cause is that the domain <unique_identifier>_oas contains an underscore (_), which is not a valid character for DNS hostnames according to RFC 1035.

Underscores are not supported in public DNS hostnames and cause TLS clients to reject the request during the handshake phase.

Requests to generated mockbin URLs should use valid domain names (only LDH characters: letters, digits, hyphens).

Could you please investigate this problem?

Thanks a lot!
</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #67


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

@vercel
Copy link

vercel bot commented Oct 11, 2025

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

Project Deployment Preview Updated (UTC)
mockbin Ready Ready Preview Oct 11, 2025 9:03pm

@zuplo
Copy link

zuplo bot commented Oct 11, 2025

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

Name Status Preview Updated (UTC)
Zuplo API ✅ Ready (Inspect) Visit Preview Oct 11, 2025, 09:04 PM

@Copilot Copilot AI changed the title [WIP] Fix invalid character in domain for OpenAPI Bin creation Fix invalid underscore in domain names for OpenAPI bins Oct 11, 2025
Copilot finished work on behalf of ntotten October 11, 2025 21:05
@Copilot Copilot AI requested a review from ntotten October 11, 2025 21:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants