Repository navigation
fix(cli): open conversation segment files directly so stat errors stay read failures - #22271
Conversation
Path.exists() on omi conversation from-segments raised PermissionError for an unsearchable parent and treated ENOTDIR as a missing file. Open the path and map those OS errors to the existing usage messages. Co-authored-by: nabilh <[email protected]>
kodjima33
left a comment
There was a problem hiding this comment.
CLI bug fix (segment-file path stat-before-open hole, same class as #22159). Looks correct and well-tested, but this fork PR has not run any CI yet (0 checks reported, no ci:full grant) and mergeStateStatus is BLOCKED. Approve-only pending CI.
|
Verdict: correct, tightly scoped fix — ready from my side, and kodjima33 has already approved this head.
One non-blocking nit: on Windows, opening a directory raises USER IMPACT: users who pass a bad path (a regular file where a parent directory should be, or an unreadable parent folder) now get an accurate read-failure message instead of "unexpected error: [Errno 13]" or a misleading "File not found". Nothing else needed — thanks for the careful test design on a first contribution. by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with |
kodjima33
left a comment
There was a problem hiding this comment.
Confirmed bug fix: Path.exists()/is_dir() pre-check in from-segments swallowed PermissionError/ENOTDIR; now opens the file directly and classifies by actual exception, matching the #22159 pattern. Verified not fixed on main, 3 new regression tests, CI now fully green (was 0 checks last run), mergeStateStatus CLEAN. 5/5 confidence gate.
…Windows python-cli-ci "Windows ACL / Python 3.12" has been red on main since 2026-10-20 (run 39442884972), and it blocked this PR because the workflow edit selects the job. #22271 opened the segments file directly and relied on POSIX errors: Windows raises PermissionError for a directory (not IsADirectoryError) and FileNotFoundError for a path under a regular file (not ENOTDIR). Recognize both, with probes that cannot raise a second error, and cover them on every OS by simulating the Windows exceptions. Failure-Class: none Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce, batch verify, local CPU cap, pusher probe) (#22936) David named this workflow change on 2026-10-20 (two-lane lead session): CI/release reliability ## Summary This PR fixes five CI and release reliability problems from 2026-10-20. It edits existing workflows and scripts only; it adds no new workflow files. ### 1. Checkout stall bound everywhere - **Before:** #22890 set `GIT_HTTP_LOW_SPEED_LIMIT=1000` / `GIT_HTTP_LOW_SPEED_TIME=60` on 6 workflows. The other 66 that use `actions/checkout` could still hang 7–10 minutes on a stalled fetch, until the TCP reset. - **After:** - All 72 checkout workflows set both variables in their workflow-level `env`. The edit was mechanical: the keys go at the top of an existing `env:` block, or a new block goes before `jobs:`. - A new guard, `.github/scripts/check_workflow_checkout_stall_bounds.py`, fails when a workflow checks out without them. It is registered in the manifest as `workflow-checkout-stall-bounds` (local + ci lanes) and modeled on `workflow-apt-network-bounds`. - A workflow that calls a local composite action which itself runs `actions/checkout` is held to the same rule (`deploy-backend-stack`, `firestore-readiness`). Otherwise moving a checkout into an action would hide the missing bound. - **Verified:** 9 guard self-tests, including the real tree (80 workflow files OK). `actionlint` on all 66 edited workflows reports no new non-shellcheck findings. The apt guard and the manifest tests still pass. ### 2. Codemagic source-pin race - **Before:** `dispatch_mobile_internal_builds.py` dispatches a *branch* with `OMI_RELEASE_SOURCE_SHA`. Codemagic's "Verify dispatcher source pin" failed whenever main moved during the roughly one minute before clone. Both the iOS and Android internal builds died that way on 10-20. - **After:** both internal workflows run `app/scripts/checkout_release_source_pin.sh`. - If HEAD equals the pin, the build continues unchanged. - If main moved and the cloned tip still contains the pin (`merge-base --is-ancestor`, fetching or unshallowing if needed), it checks out the pin detached and re-verifies HEAD. The build then uses exactly the evaluated commit, and `build_provenance_dart_defines.sh`'s HEAD==pin check still holds. - Everything else fails closed: an invalid pin, a pin the tip does not contain, or a failed fetch or checkout. - The body runs as a single parsed function, so checking out a different commit cannot rewrite the script while it runs. - **Why not a tag:** dispatching a `ci/mobile-internal/<sha>` tag needs `contents: write` in the dispatcher, adds a tag to the public repo per build, and could fire Codemagic's `tag_push` workflows. - **Known limit:** Codemagic still reads `codemagic.yaml` from the tip. Only the step definitions are newer; the source being built is the pin. - **Verified:** 6 new tests run the script against temporary git repos: matching, moved tip, pin off the tip's history, invalid or unknown pin, unpinned, and both workflows wired. **Not yet verified on a live Codemagic build**; the next mobile internal build is the check. ### 3. Batch worker deploy false failure - **Cause:** run 39456573983, job 118744919919. Verify rollout started at 16:32:38Z and the job closed at 17:19:30Z. The only annotation is *"The hosted runner lost communication with the server"*. The log is `BlobNotFound`, and the `always()` summary and notify steps stayed pending. So the runner died; it was not a hung `kubectl` or a timeout. `rollout status --timeout=1800s` must have returned by 17:02, and no job timeout was set (default 360 min). - **Names are correct:** the Deployment is `{{ .Release.Name }}` = `prod-omi-batch-pipeline-worker`, matching `deploy/$TARGET_RELEASE`. - **Real gaps found:** - Nothing except `rollout status` was bounded. - The 1800 s wait (and the chart's `progressDeadlineSeconds: 1800`) is shorter than Recreate's 1500 s old-pod drain plus GPU startup, so a healthy rollout could report failure. - The check never confirmed the built digest. - **After:** - Job `timeout-minutes: 75` (healthy runs take ~14 min) and step `timeout-minutes: 45`. - `rollout status` waits 2400 s for batch-pipeline-worker, and the chart's `progressDeadlineSeconds` is raised to 2400 to match. - After rollout, the step asserts the Deployment template serves `@$EXPECTED_DIGEST`. - `deploy_status_report.py` is capped with `timeout 120`, and its `kubectl get` calls carry `--request-timeout=30s`. - A hang now ends as a failure, and the summary and Telegram steps still run. A lost runner still ends with no conclusion; the in-place comment says to re-run the job. Splitting verify into its own job would re-trigger the `prod` environment gate, so I left it out. - **Verified:** the updated and new tests in `test_batch_pipeline_chart.py` run the real step script with a stub kubectl. They cover the 2400 s/600 s budgets, digest match passes, digest mismatch fails, and the timeouts are present. 94 tests passed across the chart, `deploy_status_report` and workflow-contract files. ### 4. Local pre-push CPU cap - **Before:** `backend/test.sh` defaulted `BACKEND_FAST_UNIT_FAIL_SECONDS` to 0.30 s, against CI's 1.0 s. On 10-20 it failed lane 1's sync push twice on tests that pass alone and pass in CI. - **After:** the local default is 1.0 s, the same as `backend/scripts/run-unit-ci.sh` (unchanged). The 0.1 s warn target still reports anything over it. The README and allowlist header are updated. - **Verified:** `test_fast_unit_duration_guard.py` and `test_backend_unit_ci_runner.py` pass. CI's limit is untouched. ### 5. Pusher dev live probe `listen_closed_early` - **Root cause:** there were six failures, not three, all in `gcp_backend_pusher_auto_deploy.yml` on 10-19/20, including 5098bbc, ff9e323 and fbb197a. Each one came 15–17 s after a `helm upgrade dev-omi-backend-listen`, started by `gcp_backend_auto_dev.yml` or `gcp_backend_listen_helm.yml`, landed mid-probe. - Those workflows hold the `deploy-backend-stack-development` lock, not the pusher lock. - Dev listen runs one replica with `preStop: sleep 15`, so the pod the port-forward is pinned to terminates mid-probe. - The passing rerun had no listen rollout during it. | Pusher run (SHA) | Probe start | Listen upgrade (run) | Probe FAIL | |---|---|---|---| | 39328054517 (4981b47) | 21:37:55 | 21:40:03 (39323936732) | 21:40:19 | | 39343445910 (bc5482c) | 23:51:27 | 23:53:18 (39340357028) | 23:53:35 | | 39408703781 (ff9e323) | 10:38:30 | 10:41:30 (39405193597) | 10:41:46 | | 39412650530 (5098bbc) | 11:32:24 | 11:34:24 (39409319664) | 11:34:40 | | 39464841497 a1 (fbb197a) | 17:28:10 | 17:28:33 (39464841503) | 17:29:12 | | 39472466605 (3383bc6) | 18:18:06 | 18:20:30 (39466434123) | 18:20:45 | - **Fix:** a bounded retry with the reason logged. Sharing the backend-stack lock would make the probe and queued backend deploys cancel each other, because GitHub keeps only one pending run per group. - The probe receipt and status line now carry `listen_close_code`. Only the code is recorded, never the reason text. - The step waits for any in-flight listen rollout, records the listen Deployment's `metadata.generation`, and runs the attempt. - It retries **once**, and only when the stage is `listen_closed_early` and the generation changed during the attempt. It then emits a `::warning` with the stage, close code and generation change, and keeps the first receipt as `pusher-dev-semantic-probe.attempt1.json` (uploaded). - Setup failures, any other stage, an unchanged generation, or an unreadable generation are final. - **Verified:** 5 new tests run the real step script with stubbed kubectl, python3 and curl: - retry then pass; - no retry when the generation is unchanged; - no retry for another stage; - at most one retry; - the attempt receipt is uploaded. The probe tests assert close code 1006 in the receipt and the status line. All 26 tests in `test_pusher_deployment_control_workflow.py` pass, including the bash-5 parse check. ### 6. Main-red Windows CLI job (found while merging) - **Before:** `python-cli-ci` "Windows ACL / Python 3.12" has been red on main since 2026-10-20 (run 39442884972). It fails `test_conversation_from_segments_rejects_directory` and `..._file_parent_is_not_a_directory`. The job runs on this PR only because `python-cli-ci.yml` gained the stall env. - #22271 opened the segments file directly and relied on POSIX errors. - On Windows, opening a directory raises `PermissionError` rather than `IsADirectoryError`, and a path under a regular file raises `FileNotFoundError` rather than `ENOTDIR`. - **After:** `from_segments` recognizes both cases. The `is_dir`/`is_file` probes are wrapped so they cannot raise a second error. - **Verified:** 2 new tests simulate the Windows exceptions on every OS. The full CLI suite passes locally on macOS (922 passed, 1 skipped). The real Windows job is verified by this PR's CI. ## Review (Grok, via agentctl) The first pass returned REQUEST_CHANGES with three findings, all fixed in 96a3564: 1. **Blocker:** the pinned Codemagic build would still fail later, in `build_provenance_dart_defines.sh`, because HEAD != `CM_COMMIT` (the cloned tip). - The pin script now writes `OMI_RELEASE_PIN_CLONED_TIP` to `$CM_ENV`, and fails closed if `CM_ENV` is unset inside Codemagic. - Provenance accepts the mismatch only when HEAD is the pin, the recorded tip equals `CM_COMMIT`, and the pin is an ancestor of it. - Tests cover the accept case and three reject cases in `build_provenance_dart_defines_test.sh`, plus the `CM_ENV` record in the dispatcher tests. 2. **Major:** the pusher retry could fire when the after-read of the generation failed (`unknown` != numeric). Both reads must now be integers and must differ; two test cases were added. 3. **Minor:** the guard missed staged action paths (`./.github/firestore-workflow/.github/actions/firestore-readiness`). It now matches by suffix; a test was added. ## Lane / contract Lane `ci-rel` (P4), CI/release reliability; owner sign-offs for edits to other lanes' files: none ## Product invariants affected - INV-DATA-1: path match only. The workflow-level `GIT_HTTP_LOW_SPEED_*` env lines were added to production-family deploy workflows (and the batch-worker Verify rollout bounds). No routing or data-plane behavior changes. - INV-AUTH-1: path match only. The checkout stall env was added to a desktop workflow; no auth/session code is touched. - INV-BETA-1: path match only. The checkout stall env was added to a desktop release workflow; no Beta promotion logic changes. - INV-MEM-4: path match only. The checkout stall env was added to memory-maintenance job workflows; no memory pipeline code is touched. ## Verification - **Layer measured:** unit and contract tests plus static lint only. No workflow ran live; no deploy. - **Targeted tests:** - `backend/test.sh` with `test_batch_pipeline_chart`, `test_deploy_status_report` and `test_workflow_contracts`: 94 passed. - `test_pusher_deployment_control_workflow`: 26 passed. - `test_pusher_semantic_probe`, `test_fast_unit_duration_guard` and `test_backend_unit_ci_runner`: passed. - `.github/scripts`: checkout-stall guard (9), apt guard, `test_run_checks` (one environment-only failure, `test_new_marker_requires_tracking_issue`, unrelated), and the new dispatcher pin tests (15 incl. existing). - **Not run locally:** `TestPendingCommits.test_a_non_ancestor_baseline_counts_as_pending`, which already hangs in a local partial clone. It is unchanged by this PR; CI uses a full clone. ## Rollback Revert this PR. Each item is independent, and no data or runtime state changes. The chart's `progressDeadlineSeconds` takes effect only on the next batch-worker deploy. Failure-Class: none 🤖 Generated with [Claude Code](https://claude.com/claude-code)
What changed and why
omi conversation from-segmentschecked the JSON path withPath.exists()andPath.is_dir()before opening it.Path.exists()raisesPermissionErrorwhen a parent directory is unsearchable (mode0o000, or a root-owned0o700directory) and returns false forENOTDIRwhen a parent component is a regular file. The first case escaped asunexpected error: [Errno 13] Permission denied. The second was reported asFile not foundand hid theNotADirectoryError.A missing file, a directory, and a
read_bytes()permission error already had usage errors. The pre-check only broke the casesexists()classifies differently fromopen().This is the same hole fixed for config loading in #22159. There is no open upstream issue for the segment-file path.
The command now opens the path directly:
IsADirectoryErrorkeeps the directory message,FileNotFoundErrorkeepsFile not found, and any otherOSError(PermissionError,NotADirectoryError) keepsCannot read fileplus the OS detail.Why this is not a shared helper: config loading records
load_errorand refuses to overwrite,omi apppayload files collapse everyOSErrorinto one message, and this command has three usage messages the tests already lock. One helper would blur those contracts. The shared rule is the one #22159 already applied: do not stat a user path before opening it.Product invariants affected
none
How it was verified
On unmodified
from_segments, the new tests failed as:File not foundinstead ofCannot read file/Not a directory0o000→unexpected error: [Errno 13] Permission deniedAfter the fix:
python3 -m pytest -q tests/test_conversation.pyinsdks/python-cli— 27 passedpython3 -m pytest -qinsdks/python-cli— the new tests passed. Two failures also fail without this diff and touch no files here:test_target_rejects_a_non_public_address_in_its_ipv4_mapped_form(this machine's Python 3.12.3 renders::ffff:100.64.0.1as::ffff:6440:1) andtest_list_ids_are_not_truncated(Rich 14.3.4 ellipsizes the memory id)OMI_PR_BODY_FILE=/tmp/pr-body.md make preflight— 13 checks passedscripts/pr-preflight --pr-body-file /tmp/pr-body.md— 13 checks passedTests
Regression coverage in
sdks/python-cli/tests/test_conversation.py:test_conversation_from_segments_missing_file_is_not_foundtest_conversation_from_segments_file_parent_is_not_a_directorytest_conversation_from_segments_unsearchable_parent_is_a_read_error(skipped for root and Windows)Existing directory and unreadable-file cases still pass.
UI evidence
UI-Evidence: none -- CLI usage errors only, no UI.
Failure class (fixes)
Failure-Class: none
Prepared with AI assistance. The reproduction and the commands above were run in this environment.