Skip to content

test(context_engine): skip the chmod attachment case when the runner is root - #313

Open
Handsome-wzw wants to merge 1 commit into
mainfrom
test/skip_chmod_case_as_root
Open

test(context_engine): skip the chmod attachment case when the runner is root#313
Handsome-wzw wants to merge 1 commit into
mainfrom
test/skip_chmod_case_as_root

Conversation

@Handsome-wzw

Copy link
Copy Markdown

Summary

test_an_attachment_that_cannot_be_read_costs_a_note_not_the_turn makes a file
unreadable with chmod 000 and asserts the renderer notes the failed attachment
instead of failing the whole turn. chmod 000 does not block a root user, so
the file stays readable, the error path is never entered, and the case fails for
anyone running the suite as root. It passes in CI, which does not run as root,
so the failure is invisible there and shows up only on a developer's machine.

Skipped for root rather than reworked: the behaviour under test is what happens
when a read raises, and making that happen without permissions means faking the
error, which would test the mock. The case is worth keeping for the runs that
can exercise it honestly.

The commit is 0xKT's, cherry-picked from the GitLab trunk where it already
landed. Authorship is preserved.

Type

  • Fix
  • Feature
  • Docs
  • CI / tooling
  • Refactor
  • Other

Test-only.

Verification

uv run pytest tests/test_read_file_image.py    105 passed, 1 skipped

Before this, the same command as root gave 1 failed, 105 passed, with the
failure on this case. The skip reason names the cause, so a reader is not left
guessing why it is absent.

  • Relevant tests pass locally
  • Relevant lint / type checks pass locally
  • User-facing docs or screenshots are updated when needed

Risk

None to the product: no source file is touched. Non-root runs, CI included,
execute the case exactly as before.

  • Security impact considered
  • Backward compatibility considered
  • Rollback path is clear for risky changes

Related Issues

N/A

…is root

The case chmods a file to 000 and expects `build_user_content` to report an
unreadable attachment as a note. Root ignores the mode bits, so the read
succeeds, the picture is inlined, and the assertion sees content blocks where it
wanted a string. Our runner is root; GitHub's is not, which is why the case
arrived green from upstream and failed here on its first run.

Guarded rather than rewritten: the behaviour under test is worth pinning where
permissions actually apply. Same spelling as the existing guard in
tests/test_importer_hermes_skills.py. `os` moves to module scope because the
decorator is evaluated there.

Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com>
@0xKT

0xKT commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

@claude review

@claude

claude Bot commented Aug 13, 2026

Copy link
Copy Markdown

Claude finished @0xKT's task in 2m 19s —— View job


Review: test(context_engine): skip the chmod attachment case when the runner is root

Verdict: looks good, no blocking issues.

What the diff does

tests/test_read_file_image.py:

  • adds import os at module scope (line 12)
  • adds @pytest.mark.skipif(os.geteuid() == 0, reason="chmod 000 does not block root") above test_an_attachment_that_cannot_be_read_costs_a_note_not_the_turn (line 1619)
  • drops the now-redundant local import os inside the test body

Checks performed

  • Correctness of the guard: chmod 0o000 (line 1629) genuinely does not block reads for euid == 0 (root ignores DAC permission bits), so the read succeeds, render.build_user_content returns content blocks instead of the "could not be read" string, and the assertions on lines 1635-1637 would fail under root. The skipif correctly prevents that false failure without weakening the assertions for the normal (non-root) path.
  • Consistency: the guard's predicate and reason string are copied verbatim from the existing precedent in tests/test_importer_hermes_skills.py:71 and :517 (os.geteuid() == 0, "chmod 000 does not block root"), so this follows an established repo pattern rather than inventing a new one.
  • No leftover duplicate import: confirmed only one import os remains in the file (module scope), no shadowing.
  • Scope not silently narrowed: the finally: os.chmod(locked, 0o644) cleanup and the rest of the test body are untouched — only the skip condition and import location changed.
  • AGENTS.md conventions:
    • branch name test/skip_chmod_case_as_root matches <type>/<snake_desc> (§2.1)
    • commit header test(context_engine): skip the chmod attachment case when the runner is root — valid type, context_engine is a real top-level raven/ subpackage, lowercase start, no trailing period, 76/100 chars (§3.1)
    • commit body is English, ASCII-only (verified via grep -P "[^\x00-\x7F]", no hits) (§3.1.1)
    • Co-authored-by: Claude (claude-opus-5) <noreply@anthropic.com> trailer present (§3.3)
    • test file naming (tests/test_read_file_image.py) is an existing file, unchanged filename, consistent with §5.1

Minor observations (non-blocking)

  • The PR body says this is cherry-picked from a GitLab trunk commit authored by 0xKT, with authorship preserved — consistent with the commit's Author: field (0xKT <74288668+0xKT@users.noreply.github.com>).
  • Could not execute uv run pytest in this sandbox (Bash tool calls requiring approval were denied in this session), so I verified the logic by static inspection and by cross-referencing the identical guard pattern already in use elsewhere in the repo, rather than by executing the suite. The PR description's own verification output (105 passed, 1 skipped locally, 1 failed, 105 passed before the fix as root) is consistent with the code change.

No changes requested.

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.

2 participants