Skip to content

test(tail): add scenarios for edge cases flagged in PR #26 review#97

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits intomainfrom
jules.macret/re-review-tail
Mar 16, 2026
Merged

test(tail): add scenarios for edge cases flagged in PR #26 review#97
gh-worker-dd-mergequeue-cf854d[bot] merged 2 commits intomainfrom
jules.macret/re-review-tail

Conversation

@julesmcrt
Copy link
Collaborator

Add three missing scenario tests for security/correctness edge cases identified in the chatgpt-codex-connector review of PR #26:

  • malformed_offset_plus_minus: rejects -n +-3 as invalid (not valid GNU tail)
  • malformed_offset_plus_plus: rejects -c ++5 as invalid (not valid GNU tail)
  • minint64_overflow: rejects -9223372036854775808 without panicking (negation overflows back to negative in two's complement)

All three cases are already handled correctly by parseCount() in tail.go; these scenarios document and protect that behaviour.

What does this PR do?

Motivation

Testing

Checklist

  • Tests added/updated
  • Documentation updated (if applicable)

Add three missing scenario tests for security/correctness edge cases
identified in the chatgpt-codex-connector review of PR #26:

- malformed_offset_plus_minus: rejects -n +-3 as invalid (not valid GNU tail)
- malformed_offset_plus_plus: rejects -c ++5 as invalid (not valid GNU tail)
- minint64_overflow: rejects -9223372036854775808 without panicking (negation
  overflows back to negative in two's complement)

All three cases are already handled correctly by parseCount() in tail.go;
these scenarios document and protect that behaviour.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@julesmcrt
Copy link
Collaborator Author

@codex review

Copy link

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

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: 69d0979cd2

ℹ️ 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 on lines +11 to +14
stdout: ""
stderr_contains: ["tail:"]
exit_code: 1
skip_assert_against_bash: true

Choose a reason for hiding this comment

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

P1 Badge Match MinInt64 scenario with GNU tail behavior

tail -n -9223372036854775808 file.txt is accepted by GNU tail (coreutils) and returns exit code 0 (it prints the file when it has fewer than that many lines), but this scenario asserts exit_code: 1 with stderr_contains and then disables bash parity via skip_assert_against_bash: true. That locks in a known divergence instead of catching it, which conflicts with the test suite’s bash-compatibility goal for non-restricted behavior.

Useful? React with 👍 / 👎.

Three fixes:

1. tail: clamp MinInt64 instead of rejecting it
   -(-9223372036854775808) overflows back to itself, but GNU tail
   accepts this value and prints the file (treating it as a large count).
   Change parseCount to clamp to MaxCount on overflow rather than return
   invalid, matching bash/GNU tail behaviour.

2. interp: remove runtime/debug.Stack from panic recovery
   The stack trace leaks internal details; the panic value alone is
   sufficient. This drops the runtime/debug import from api.go and
   runner_exec.go, fixing the allowedsymbols test failure.

3. interp: use io.Discard as panic fallback instead of os.Stderr
   When the runner has no stderr configured, the previous code fell back
   to os.Stderr, bypassing the embedder's I/O contract. Use io.Discard
   so the message is silently dropped; the caller still receives
   "internal error" via the returned error. This also drops os.Stderr
   from the interp allowlist.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@julesmcrt
Copy link
Collaborator Author

@codex review

@chatgpt-codex-connector
Copy link

Codex Review: Didn't find any major issues. Keep it up!

ℹ️ 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".

@julesmcrt julesmcrt marked this pull request as ready for review March 16, 2026 13:29
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot merged commit 680f119 into main Mar 16, 2026
44 of 45 checks passed
@gh-worker-dd-mergequeue-cf854d gh-worker-dd-mergequeue-cf854d bot deleted the jules.macret/re-review-tail branch March 16, 2026 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants