[PR #4123] [MERGED] fix(website): handle UTF-8 output and slash refs in link audits #6071

Closed
opened 2026-10-31 01:11:38 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/4123
Author: @kuxiaowo
Created: 10/15/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: developing


📝 Commits (1)

  • 30e0ca1 fix(website): handle UTF-8 output and slash refs in link audits

📊 Changes

2 files changed (+113 additions, -2 deletions)

View changed files

📝 scripts/audit-website-links.py (+3 -2)
📝 scripts/test-website.py (+110 -0)

📄 Description

Summary

The optional website link auditor can crash while decoding GitHub CLI JSON on a GBK Windows host, and marks valid raw GitHub links as broken when their branch or tag contains /. Decode the CLI response as UTF-8 and route raw links through the existing ref/path resolver used by browser links.

Problem and expected behavior

  • On Windows with Python 3.12 and UTF-8 mode disabled, auditing REA's rea-agents-6.5.0 release raises a GBK UnicodeDecodeError, followed by json.loads(None). The same response should parse regardless of the host locale.
  • https://raw.githubusercontent.com/morluto/rea/docs/beginner-setup-guide/README.md returns HTTP 200, but the auditor requests ref docs and reports HTTP 404. It should resolve docs/beginner-setup-guide, as it already does for the corresponding github.com/.../blob/... URL.

These findings came from source review and live GitHub probes; no separate issue was opened. A search of the open PR file lists found no existing change to this auditor.

Change and scope

Specify UTF-8 at the subprocess boundary. Normalize the omitted blob segment in raw URLs so ref selection and path quoting have one owner. Add offline regressions to the existing website test runner; no website content, business logic, or agent instructions change.

Contract and boundary impact

  • Semantic owner and earliest changed stage: scripts/audit-website-links.py, GitHub response decoding and URL resolution.
  • Contribution scope fit and linked maintainer decision: routine fixes within the existing optional auditor; a new-provider/target-execution scope decision is not applicable.
  • CLI and MCP/tool-catalog contract: audit report shape and error classifications remain unchanged; no REA CLI/MCP contract changes.
  • Provider, bridge, target-format, or platform compatibility: GBK Windows transport regression covered; no analysis-provider changes.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details: existing GitHub GET requests through gh; no target acquisition or mutation.
  • Generated metadata, package, or installation impact: none; generated website outputs remain uncommitted.

Expected effects of the existing audit workflow:

  • Read existing files or captured data.
  • Launch or attach to a process (gh only).
  • Contact network services (GitHub GET requests).

Evidence and regression coverage

  • A real child process writes UTF-8 JSON bytes while UTF-8 mode is disabled and the default locale is set to cp936. The regression exercises actual pipe decoding rather than returning a pre-decoded mocked string.
  • URL cases cover slash-containing branches and tags, an encoded ref, encoded filename characters, ordinary refs, pinned commits, and the distinction between missing contents, denied access, and timeouts.
  • Running the new test class against the base auditor produces three failures: legacy-locale decoding and two raw-link subcases. The fixed implementation passes all four tests.
  • Live Windows probes now report ok for the release and both forms of the slash-branch README link; direct raw HTTP access remains 200.
  • Remaining proof gaps: the complete live external-link inventory and a separate Linux run were not executed. No analysis-engine verification is needed for this maintenance-script-only change.

Validation performed

  • python scripts/test-website.py WebsiteLinkAuditChecks — 4 tests passed.
  • python scripts/website.py check — passed: 382 HTML pages, 26,087 local references, metadata/sitemap checks, and all 20 website regression tests.
  • npm run check — passed with Node 24.18.0 / npm 11.16.0; lint reported zero errors and existing warnings.
  • npm run verify:test-discovery — all 1,344 tracked test files discovered exactly once.
  • git diff --check — passed.

Python checks used a Conda Python 3.12 environment. The full website check uses PYTHONUTF8=1; the new transport regression explicitly disables UTF-8 mode in its child process.

Compatibility, safety, and release

  • No breaking changes, migrations, package metadata changes, or new target authority.
  • Non-SHA raw URLs now perform the same two cached ref lookups as browser URLs. Fixed SHA URLs still skip these lookups. A single live main/README.md probe measured one/three cold gh calls before/after (1.21/3.24 seconds); both warm probes made zero calls. These network-dependent samples are diagnostic, not an isolated performance benchmark. Python-parent CPU was 0.000/0.031 seconds cold; process-family CPU and peak memory were not measured. There are no agent-payload/token changes.
  • Real Hopper/Ghidra/browser analysis was not run because those paths are unchanged. Native Windows link-auditor behavior was exercised.

Author readiness

Human owner: @kuxiaowo

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. No separate scope decision is required for this routine maintenance-script fix.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed. Not applicable: none require changes for these auditor fixes.
  • User-visible CLI/MCP changes include representative output. Not applicable: no REA CLI/MCP interface changes.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/4123 **Author:** [@kuxiaowo](https://github.com/kuxiaowo) **Created:** 10/15/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `developing` --- ### 📝 Commits (1) - [`30e0ca1`](https://github.com/morluto/rea/commit/30e0ca15f88c081609389ce7b8939c99bf69c741) fix(website): handle UTF-8 output and slash refs in link audits ### 📊 Changes **2 files changed** (+113 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `scripts/audit-website-links.py` (+3 -2) 📝 `scripts/test-website.py` (+110 -0) </details> ### 📄 Description ## Summary The optional website link auditor can crash while decoding GitHub CLI JSON on a GBK Windows host, and marks valid raw GitHub links as broken when their branch or tag contains `/`. Decode the CLI response as UTF-8 and route raw links through the existing ref/path resolver used by browser links. ## Problem and expected behavior - On Windows with Python 3.12 and UTF-8 mode disabled, auditing REA's `rea-agents-6.5.0` release raises a GBK `UnicodeDecodeError`, followed by `json.loads(None)`. The same response should parse regardless of the host locale. - `https://raw.githubusercontent.com/morluto/rea/docs/beginner-setup-guide/README.md` returns HTTP 200, but the auditor requests ref `docs` and reports HTTP 404. It should resolve `docs/beginner-setup-guide`, as it already does for the corresponding `github.com/.../blob/...` URL. These findings came from source review and live GitHub probes; no separate issue was opened. A search of the open PR file lists found no existing change to this auditor. ## Change and scope Specify UTF-8 at the subprocess boundary. Normalize the omitted `blob` segment in raw URLs so ref selection and path quoting have one owner. Add offline regressions to the existing website test runner; no website content, business logic, or agent instructions change. ## Contract and boundary impact - Semantic owner and earliest changed stage: `scripts/audit-website-links.py`, GitHub response decoding and URL resolution. - Contribution scope fit and linked maintainer decision: routine fixes within the existing optional auditor; a new-provider/target-execution scope decision is not applicable. - CLI and MCP/tool-catalog contract: audit report shape and error classifications remain unchanged; no REA CLI/MCP contract changes. - Provider, bridge, target-format, or platform compatibility: GBK Windows transport regression covered; no analysis-provider changes. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details: existing GitHub GET requests through `gh`; no target acquisition or mutation. - Generated metadata, package, or installation impact: none; generated website outputs remain uncommitted. Expected effects of the existing audit workflow: - [x] Read existing files or captured data. - [x] Launch or attach to a process (`gh` only). - [x] Contact network services (GitHub GET requests). ## Evidence and regression coverage - A real child process writes UTF-8 JSON bytes while UTF-8 mode is disabled and the default locale is set to cp936. The regression exercises actual pipe decoding rather than returning a pre-decoded mocked string. - URL cases cover slash-containing branches and tags, an encoded ref, encoded filename characters, ordinary refs, pinned commits, and the distinction between missing contents, denied access, and timeouts. - Running the new test class against the base auditor produces three failures: legacy-locale decoding and two raw-link subcases. The fixed implementation passes all four tests. - Live Windows probes now report `ok` for the release and both forms of the slash-branch README link; direct raw HTTP access remains 200. - Remaining proof gaps: the complete live external-link inventory and a separate Linux run were not executed. No analysis-engine verification is needed for this maintenance-script-only change. ## Validation performed - `python scripts/test-website.py WebsiteLinkAuditChecks` — 4 tests passed. - `python scripts/website.py check` — passed: 382 HTML pages, 26,087 local references, metadata/sitemap checks, and all 20 website regression tests. - `npm run check` — passed with Node 24.18.0 / npm 11.16.0; lint reported zero errors and existing warnings. - `npm run verify:test-discovery` — all 1,344 tracked test files discovered exactly once. - `git diff --check` — passed. Python checks used a Conda Python 3.12 environment. The full website check uses `PYTHONUTF8=1`; the new transport regression explicitly disables UTF-8 mode in its child process. ## Compatibility, safety, and release - No breaking changes, migrations, package metadata changes, or new target authority. - Non-SHA raw URLs now perform the same two cached ref lookups as browser URLs. Fixed SHA URLs still skip these lookups. A single live `main/README.md` probe measured one/three cold `gh` calls before/after (1.21/3.24 seconds); both warm probes made zero calls. These network-dependent samples are diagnostic, not an isolated performance benchmark. Python-parent CPU was 0.000/0.031 seconds cold; process-family CPU and peak memory were not measured. There are no agent-payload/token changes. - Real Hopper/Ghidra/browser analysis was not run because those paths are unchanged. Native Windows link-auditor behavior was exercised. ## Author readiness Human owner: @kuxiaowo - [x] I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge - [x] This PR addresses a concrete problem or an agreed enhancement. - [x] Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff. No separate scope decision is required for this routine maintenance-script fix. - [x] The PR has one focused outcome and the title follows `type(scope): outcome`. - [x] Related issue is linked, or the reason for not linking one is stated above. - [x] Tests cover changed observable behavior and meaningful failure paths. - [x] Owning docs, contracts, and generated metadata are updated where needed. Not applicable: none require changes for these auditor fixes. - [x] User-visible CLI/MCP changes include representative output. Not applicable: no REA CLI/MCP interface changes. - [x] I checked the final diff for secrets, unrelated cleanup, and unsupported claims. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-10-31 01:11:38 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6071
No description provided.