Skip to content

fix(lab-ops-hub): return IP literals in canonical form in the container validator - #638

Merged
dezren39 merged 3 commits into
mainfrom
creator/637-canonical-ip-literal
Oct 23, 2026
Merged

dezren39 merged 3 commits into
mainfrom
creator/637-canonical-ip-literal

Conversation

@dezren39

@dezren39 dezren39 commented Oct 23, 2026 •

Copy link
Copy Markdown
Member

Fixes #637

The container validator judged IP literals correctly but returned the caller's spelling verbatim (inet_aton IPv4 forms like 134744072, 1.2.256, 010.0.0.010; expanded/uppercase IPv6). The Worker returns the WHATWG-canonical form. The IP-literal success path now returns _url_with_host(u, str(ip)) — the canonical dotted quad / compressed lowercase IPv6 of the address that was judged — matching validateCrawlUrl return-for-return on the #637 probe table, including IPv4-mapped forms ([::ffff:8.8.8.8] → [::ffff:808:808]).

Tests: new test_returns_ip_literals_in_canonical_form (11 cases incl. userinfo+port preservation); two pre-existing verbatim pins updated to the canonical expectation (integer-spelling accept case, IPv4-mapped dotted spelling). Python suite: 51/51 pass. Differential probe vs the Worker validator: all IP-literal diffs eliminated; verdicts unchanged everywhere.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

Summary by CodeRabbit

  • Bug Fixes
    • URLs containing public IP addresses are now returned in a consistent canonical form, including normalized IPv4 and IPv6 spellings. User information and port numbers are preserved where present.
    • This covers alternate representations such as integer, hexadecimal, octal, abbreviated, and expanded IP addresses.

@dezren39
dezren39 requested a review from a team as a code owner October 23, 2026 02:18
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-23T02:33:16.800989Z 746769c New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 50 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5d8371af-09cf-4eec-b247-84b9980d1054
📥 Commits

Reviewing files that changed from the base of the PR and between fecc932 and 746769c.

📒 Files selected for processing: 1
  • pkgs/lab-ops-hub/container/app.py

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: da306b4d-e066-4d30-b5db-164dac651beb
📥 Commits

Reviewing files that changed from the base of the PR and between 5a84351 and fecc932.

📒 Files selected for processing: 2
  • pkgs/lab-ops-hub/container/app.py
  • pkgs/lab-ops-hub/test/test_container_validate.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Walkthrough

validate_crawl_url now returns accepted IP-literal URLs with the parsed address in canonical form. Tests cover noncanonical IPv4 and IPv6 spellings and verify that userinfo and port are preserved.

Changes: IP URL canonicalization

Layer / File(s) Summary
Canonicalize accepted IP-literal URLs
pkgs/lab-ops-hub/container/app.py, pkgs/lab-ops-hub/test/test_container_validate.py
After public-address checks, validate_crawl_url replaces the URL host with str(ip). Tests check canonical IPv4 and IPv6 returns, including preserved userinfo and port. The translation-prefix test checks the canonical IPv6 form.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to fecc9

The canonical IP return change is ready to merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: returning IP literals in canonical form from the container validator.
Linked Issues check Passed Issue #637 requires canonical returned forms for accepted IP literals, unchanged verdicts, regression tests, a passing Python suite, and no TypeScript changes. The diff changes the successful IP-liter…
Out of Scope Changes check Passed The whole-PR diff contains changes only in pkgs/lab-ops-hub/container/app.py and its Python test file. The implementation changes only the successful IP-literal return path. The tests directly verif…
Full details: Linked Issues check

Explanation

Issue #637 requires canonical returned forms for accepted IP literals, unchanged verdicts, regression tests, a passing Python suite, and no TypeScript changes. The diff changes the successful IP-literal path to call _url_with_host(u, str(ip)), which produces canonical IPv4 and IPv6 forms while preserving URL components. The added test covers 11 IPv4 and IPv6 cases, including userinfo, port, and IPv4-mapped IPv6 input. The PR reports 51/51 Python tests passing, unchanged verdicts, and no TypeScript changes.

Full details: Out of Scope Changes check

Explanation

The whole-PR diff contains changes only in pkgs/lab-ops-hub/container/app.py and its Python test file. The implementation changes only the successful IP-literal return path. The tests directly verify issue #637 canonical-return behavior. No DNS-name behavior or unrelated TypeScript code changes are present.

✨ Finishing Touches: 💡 2
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🛠️ Fix failing CI checks: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fecc932909

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread pkgs/lab-ops-hub/container/app.py Outdated
# spelling. (A percent-decoded host is likewise fetched in its
# decoded form, #529.) _url_with_host re-adds the brackets for
# an IPv6 literal.
return _url_with_encoded_components(_url_with_host(u, str(ip)))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Serialize mapped IPv6 independently of Python's display form

On the declared python:3.13-alpine runtime, str(ipaddress.ip_address("::ffff:8.8.8.8")) returns ::ffff:8.8.8.8, not the WHATWG form ::ffff:808:808. Consequently this new path leaves mapped literals noncanonical and the added assertion in test_judges_translation_prefixes_by_embedded_ipv4 fails under Python 3.13 (and 3.14), while Node's URL serializer returns the expected hex form. IPv4-mapped IPv6 addresses need an explicit hextet-based serialization rather than str(ip).

Useful? React with 👍 / 👎.

@dezren39

Copy link
Copy Markdown
Member Author

Follow-up commit: CI (Python 3.12.15) rendered str(IPv6Address) for an IPv4-mapped address as ::ffff:8.8.8.8 while this sandbox's Python 3.12.3 and the Worker's serializer both give hextets ::ffff:808:808 — str() is patch-version-unstable for mapped addresses. The fix now renders IPv6 via a small _canonical_ipv6 (exploded hextets + longest-zero-run compression), verified against node's URL serializer on mapped/6to4/NAT64/compression edge cases; 51/51 Python tests pass locally.

@dezren39
dezren39 merged commit 9298c5f into main Oct 23, 2026
5 checks passed
@dezren39
dezren39 deleted the creator/637-canonical-ip-literal branch October 23, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant