Skip to content

fix(scripts): validate i18n bundle dist flag#3071

Merged
senamakel merged 3 commits into
tinyhumansai:mainfrom
alexzhu0:codex/OH-2611-verify-i18n-dist-arg
Jun 2, 2026
Merged

fix(scripts): validate i18n bundle dist flag#3071
senamakel merged 3 commits into
tinyhumansai:mainfrom
alexzhu0:codex/OH-2611-verify-i18n-dist-arg

Conversation

@alexzhu0
Copy link
Copy Markdown
Contributor

@alexzhu0 alexzhu0 commented May 31, 2026

Summary

  • Makes scripts/verify-i18n-bundle.mjs --dist reject missing path values before filesystem checks.
  • Treats another flag, such as --help, as a missing --dist value instead of a directory path.
  • Adds focused Node tests for the argument parsing edge cases.

Problem

  • node scripts/verify-i18n-bundle.mjs --dist --help currently resolves --help as a directory.
  • The script then reports a missing dist directory instead of the real argument error.
  • That makes CLI mistakes harder to diagnose in local validation and CI logs.

Solution

  • Require the --dist value to be present and not start with -.
  • Preserve existing --help behavior when --help is used as the actual top-level flag.
  • Cover both missing-value paths with root node:test tests.

Submission Checklist

If a section does not apply to this change, mark the item as N/A with a one-line reason. Do not delete items.

  • Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy
  • N/A: Diff coverage gate was not run because this is a root helper script change and local Rust tooling is unavailable.
  • N/A: Coverage matrix not affected; this does not add, remove, or rename a product feature.
  • N/A: No affected feature IDs; helper CLI only.
  • No new external network dependencies introduced (mock backend used per Testing Strategy)
  • N/A: Manual smoke checklist not affected; this does not touch release-cut surfaces.
  • N/A: Related to [Automated] Weekly code-review report — 2026-05-25 #2611 but does not close it by itself.

Impact

  • Runtime/platform impact: none.
  • Developer impact: i18n bundle validation now reports malformed --dist usage directly.

Related


AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: codex/OH-2611-verify-i18n-dist-arg
  • Commit SHA: 91eac1f

Validation Run

  • pnpm --filter openhuman-app format:check (blocked after app Prettier passed; see below)
  • pnpm typecheck
  • Focused tests: node --test scripts/__tests__/verify-i18n-bundle-args.test.mjs
  • Rust fmt/check (if changed): N/A, no Rust files changed
  • Tauri fmt/check (if changed): N/A, no Tauri files changed
  • node scripts/verify-i18n-bundle.mjs --dist --help
  • node scripts/verify-i18n-bundle.mjs --help
  • node scripts/codex-pr-preflight.mjs --lightweight
  • git diff --check

Validation Blocked

  • command: env COREPACK_HOME=/Users/alex/PR/.corepack PNPM_HOME=/Users/alex/PR/.pnpm-home pnpm --filter openhuman-app format:check
  • error: sh: cargo: command not found
  • impact: The app Prettier phase passed, but Rust formatting and the pre-push hook cannot complete in this local environment until Cargo is installed.

Behavior Changes

  • Intended behavior change: --dist now exits 2 when its value is missing or another flag.
  • User-visible effect: contributor-facing validation errors are clearer.

Parity Contract

  • Legacy behavior preserved: valid --dist <path>, top-level --help, and unknown-argument handling remain unchanged.
  • Guard/fallback/dispatch parity checks: focused tests cover missing path and flag-as-path dispatch branches.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): none found during triage
  • Canonical PR: this PR
  • Resolution (closed/superseded/updated): N/A

Summary by CodeRabbit

  • Tests

    • Added test cases for CLI argument validation to ensure the --dist flag properly rejects invalid inputs and exits with appropriate error messages.
  • Bug Fixes

    • Improved validation for the --dist flag to reject values that appear to be other CLI flags, in addition to missing values.

Constraint: The i18n bundle verifier accepts a path-valued --dist flag and should fail before filesystem checks when the path is missing.

Rejected: Treat the next flag as a directory path | it turns argument mistakes into misleading missing-directory errors.

Confidence: high

Scope-risk: narrow

Directive: Keep path-valued validation flags strict about missing values.

Tested: node --test scripts/__tests__/verify-i18n-bundle-args.test.mjs; node scripts/verify-i18n-bundle.mjs --dist --help; node scripts/verify-i18n-bundle.mjs --help; node scripts/codex-pr-preflight.mjs --lightweight; pnpm typecheck; git diff --check

Not-tested: Full format:check/pre-push hook; cargo is not installed in this environment, though the app Prettier phase passed.
@alexzhu0 alexzhu0 requested a review from a team May 31, 2026 05:39
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 31, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 2aa08bf9-358c-4f05-a162-1c3ca127e7d6

📥 Commits

Reviewing files that changed from the base of the PR and between 91eac1f and 889bbbc.

📒 Files selected for processing (1)
  • scripts/__tests__/verify-i18n-bundle-args.test.mjs
🚧 Files skipped from review as they are similar to previous changes (1)
  • scripts/tests/verify-i18n-bundle-args.test.mjs

📝 Walkthrough

Walkthrough

The PR tightens CLI argument validation in verify-i18n-bundle.mjs by rejecting --dist values that are either missing or appear to be another flag (start with -). A new test file validates this behavior using subprocess execution, confirming correct exit codes and error messages.

Changes

CLI argument validation improvement

Layer / File(s) Summary
Stricter --dist argument validation
scripts/verify-i18n-bundle.mjs, scripts/__tests__/verify-i18n-bundle-args.test.mjs
The --dist flag parser now rejects values that are absent or resemble CLI flags (start with -). Two subprocess-based tests validate exit status 2, the error message --dist requires a path, and absence of filesystem-related dist-missing errors.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • tinyhumansai/openhuman#2403: Introduced the i18n bundle verification script that this PR now enhances with stricter argument validation and test coverage.

Suggested reviewers

  • graycyrus

Poem

A rabbit runs to check the flags,
When --dist slips into foggy slags,
It hops and sniffs — "this isn't a path!"
It stamps its paw, asserts the math,
Tests cheer: the CLI won't be had. 🐰✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ 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%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ 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 'fix(scripts): validate i18n bundle dist flag' accurately describes the main change: adding validation for the --dist flag in the i18n bundle verification script.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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


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.

coderabbitai[bot]
coderabbitai Bot previously approved these changes May 31, 2026
@alexzhu0
Copy link
Copy Markdown
Contributor Author

Thanks for the checks. I rechecked this PR on current state:

  • The only true blocker is Rust Core Coverage (cargo-llvm-cov) failing.
  • Other core checks in this PR pass; remaining failures are likely rerun / shared-suite related.
  • This is likely a shared upstream/core coverage issue across the fix(codex): compare strict preflight paths by realpath #3060-3073 batch, not a regression from this PR's diff.
  • PR Submission Checklist has historical failed/cancelled runs due to workflow re-triggers.

@alexzhu0
Copy link
Copy Markdown
Contributor Author

I reviewed all open PRs from alexzhu0 in this batch (#3060-3073).

Clarification on PR Submission Checklist

Most PR Submission Checklist failure/cancellation entries are historical/retry artifacts rather than new functional regressions:

  • Multiple checklist runs are expected for these PRs because re-runs happen while soft checks are triggered.
  • In the same PRs, CodeRabbit, lint/format, and most pipeline checks are passing.
  • The remaining hard blockers are concentrated in Rust Core Coverage (cargo-llvm-cov) and, for a subset, Frontend Coverage (Vitest) / Playwright web lane 1.

Suggested action

Please treat PR Submission Checklist failures for this batch as noise unless accompanied by a fresh diff-scope failure in core quality gates.

This should help avoid blocking PRs that are not functionally regressed by their own changes.

@sanil-23 sanil-23 assigned sanil-23 and unassigned sanil-23 May 31, 2026
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

@alexzhu0 the code looks good — fix is correct and the tests cover both edge cases cleanly. CI is failing, so i'll hold the APPROVE until those are green. once CI passes i'll come back and approve. let me know if you need help sorting out the failures.

Comment thread scripts/__tests__/verify-i18n-bundle-args.test.mjs
graycyrus
graycyrus previously approved these changes Jun 1, 2026
Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Looks good. The fix is surgical and well-tested — argument validation is now strict about missing --dist paths, which improves error diagnostics. CI is green and this is a low-risk helper script improvement.

@graycyrus graycyrus dismissed their stale review June 1, 2026 14:28

Auto-corrected: CI is failing (Rust Core Coverage), cannot approve

Copy link
Copy Markdown
Contributor

@graycyrus graycyrus left a comment

Choose a reason for hiding this comment

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

Code looks good — the fix is surgical and well-tested. However, Rust Core Coverage (cargo-llvm-cov) is failing. Once CI passes, this will be ready to merge. (The argument validation change is low-risk and the tests are excellent.)

Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

@alexzhu0 - re-checking this one. same commit since the last pass, so no new diff to review.

CI: "Rust Core Coverage (cargo-llvm-cov)" is still failing. This PR doesn't touch any Rust code, so the failure looks pre-existing or unrelated. If you haven't already, flag it to a maintainer so they can either confirm it's a known flake or triage it separately. All other checks (E2E, frontend coverage, Rust quality, i18n parity, etc.) are passing.

Code is still clean. My earlier comment about using result.stderr instead of result.stdout as the assertion message at lines 18 and 28 of the test file is still open - minor, not a blocker, but worth a quick fix before this merges so test failures give an actionable diagnostic.

Once Rust coverage CI resolves, this is good to go.

The verifier writes argument errors to stderr, so the tests should surface that stream when a status assertion fails.

Constraint: Reviewer feedback called out stdout as the wrong assertion message for these error-path tests.

Rejected: Leave the assertion message as stdout | it hides the diagnostic stream these tests are validating.

Confidence: high

Scope-risk: narrow

Directive: Use the stream under test as the failure diagnostic in CLI argument tests.

Tested: node --test scripts/__tests__/verify-i18n-bundle-args.test.mjs; git diff --check

Not-tested: Full repository format/check; local cargo binary is unavailable.
Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

@alexzhu0 the code looks good — prior comment addressed. CI isn't fully green yet so holding off on approve.

The one-line guard (!value || value.startsWith("-")) is exactly right: it covers both the trailing-flag case and the plain-missing case without disturbing valid paths or the top-level --help branch. The two tests are well-scoped — exit code, stderr message, and a negative assertion that the old misleading error no longer fires. Good structure.

Prior minor (assertion message should use stderr, not stdout): fixed in 889bbbc. Thread resolved.

CI failures currently hitting: Frontend Coverage (Vitest), Rust Core/Tauri Coverage, Coverage Gate, Rust E2E, Playwright E2E — none of these look related to a 1-line helper-script change, but they need to be green before I can approve. Once CI is green, i'll come back and approve. Let me know if any of the failures turn out to be pre-existing and there's a way to track them separately.

Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

@alexzhu0 the code looks good and all prior feedback has been addressed. CI is still failing, but the three failing checks — Rust Core Coverage, Playwright lane 1/4, and the tauri-cef submodule pin — are all pre-existing and unrelated to this JS-only script change. Once CI is green i'll come back and approve. let me know if you need help tracking down what's blocking those checks upstream.

Copy link
Copy Markdown
Contributor

@sanil-23 sanil-23 left a comment

Choose a reason for hiding this comment

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

@alexzhu0 the upstream merge looks clean — no changes to the script or test files, and all prior feedback has been addressed.

Only remaining blocker is CI: Playwright E2E lanes 1 and 2 are failing, and Rust Core Coverage is failing. These appear to be pre-existing flaky failures unrelated to this JS-only change (lanes 3/4 pass, Rust E2E passes, Rust Tauri Coverage passes). A re-run should clear them. Once CI is fully green, i'll approve.

@senamakel senamakel merged commit 468793b into tinyhumansai:main Jun 2, 2026
16 of 19 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.

4 participants