Skip to content

fix(probe): reject scheme-less endpoint URLs#56

Merged
dialupdisaster merged 1 commit into
mainfrom
fix/issue-45-probe-endpoint-validation
May 20, 2026
Merged

fix(probe): reject scheme-less endpoint URLs#56
dialupdisaster merged 1 commit into
mainfrom
fix/issue-45-probe-endpoint-validation

Conversation

@dialupdisaster
Copy link
Copy Markdown
Contributor

@dialupdisaster dialupdisaster commented May 19, 2026

Summary

  • reject endpoint URLs that parse without a hostname
  • restore the malformed no-scheme probe regression coverage
  • clarify in the README that OPENCODE_OTLP_ENDPOINT must include a scheme

Testing

  • bun run typecheck
  • bun test

Fixes #45

Summary by CodeRabbit

Release Notes

  • Documentation

    • Clarified that OPENCODE_OTLP_ENDPOINT requires full URLs with schemes (e.g., http://localhost:4317). Scheme-less values like localhost:4317 are no longer accepted.
  • Bug Fixes

    • Improved endpoint validation to reject malformed URLs without proper schemes or hostnames.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 19, 2026

📝 Walkthrough

Walkthrough

This PR validates OTLP endpoint URLs by rejecting scheme-less addresses. The parseEndpoint function now checks for hostname presence and returns null when missing. Tests are strengthened with explicit coverage for this case, and documentation is updated to clarify the full URL requirement.

Changes

Endpoint URL scheme validation

Layer / File(s) Summary
Endpoint URL hostname validation
src/probe.ts, tests/probe.test.ts
parseEndpoint validates that the parsed URL contains a hostname and returns null if missing. New test case asserts parseEndpoint("localhost:4317") returns null. The malformed URL test assertion is refined to verify the error message contains "invalid endpoint URL".
Endpoint configuration documentation
README.md
Updated OPENCODE_OTLP_ENDPOINT description to require a full URL with scheme, clarifying protocol-specific usage. Quick start section adds explicit note that scheme-less values are rejected.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Suggested reviewers

  • digitalfiz
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(probe): reject scheme-less endpoint URLs' accurately summarizes the main change—adding validation to reject scheme-less endpoint URLs in the probe module.
Linked Issues check ✅ Passed The PR implements the objective from issue #45 by adding a null check in parseEndpoint for missing hostnames, updating tests to verify rejection of scheme-less URLs, and clarifying README documentation that endpoints must include a scheme.
Out of Scope Changes check ✅ Passed All changes directly address issue #45: the parseEndpoint guard prevents scheme-less URLs, tests verify the fix, and README documentation clarifies the requirement. No out-of-scope changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-45-probe-endpoint-validation

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/probe.test.ts`:
- Around line 35-36: Remove the redundant assertion
`expect(result.error).toBeDefined()` in tests/probe.test.ts; the existing
`expect(result.error).toContain("invalid endpoint URL")` already implies
`result.error` is defined, so delete the `expect(result.error).toBeDefined()`
line to avoid duplication.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: f154f78f-6b68-4947-967b-1e572adf01c2

📥 Commits

Reviewing files that changed from the base of the PR and between 39dd93d and df7a62b.

📒 Files selected for processing (3)
  • README.md
  • src/probe.ts
  • tests/probe.test.ts

Comment thread tests/probe.test.ts
Comment on lines +35 to 36
expect(result.error).toContain("invalid endpoint URL")
expect(result.error).toBeDefined()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Remove redundant assertion.

Line 36 checking result.error is defined is redundant because line 35 already validates that result.error contains the string "invalid endpoint URL", which implicitly confirms it is defined.

🧹 Proposed fix to remove redundant assertion
     expect(result.error).toContain("invalid endpoint URL")
-    expect(result.error).toBeDefined()
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(result.error).toContain("invalid endpoint URL")
expect(result.error).toBeDefined()
expect(result.error).toContain("invalid endpoint URL")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/probe.test.ts` around lines 35 - 36, Remove the redundant assertion
`expect(result.error).toBeDefined()` in tests/probe.test.ts; the existing
`expect(result.error).toContain("invalid endpoint URL")` already implies
`result.error` is defined, so delete the `expect(result.error).toBeDefined()`
line to avoid duplication.

@dialupdisaster dialupdisaster merged commit e50a9ed into main May 20, 2026
7 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.

Pre-existing test failure: probeEndpoint accepts scheme-less URL

1 participant