Skip to content

fix: add autodie exception throwing to __sysopen#246

Merged
atoomic merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/sysopen-autodie
Feb 28, 2026
Merged

fix: add autodie exception throwing to __sysopen#246
atoomic merged 1 commit intocpanel:masterfrom
atoomic:koan.atoomic/sysopen-autodie

Conversation

@Koan-Bot
Copy link
Contributor

What

Add autodie integration to __sysopen — currently use autodie 'sysopen' silently fails on all mocked sysopen errors.

Why

__open already has autodie support (PR #208), but __sysopen was never updated. When a caller uses use autodie 'sysopen' and a mocked sysopen fails (ENOENT, EEXIST, EISDIR, etc.), autodie never throws — the error is silently swallowed. This creates a behavioral mismatch between open and sysopen under autodie.

How

  • Added _caller_has_autodie_for_sysopen() — detects autodie via caller(N)[10] hints hash (keys: autodie, Fatal::sysopen, autodie::sysopen)
  • Added _throw_autodie_sysopen() — constructs and throws autodie::exception with function => 'CORE::sysopen'
  • Extended %_autodie_callers import-time cache to detect sysopen hints alongside open
  • Inserted autodie throws at all 4 failure paths in __sysopen (EISDIR, EEXIST, ENOENT, permission errors)
  • Combined with return undef convention from PR fix: sysopen ENOENT for O_WRONLY/O_RDWR without O_CREAT #242

Testing

  • t/autodie_sysopen.t — 12 tests: ENOENT, EEXIST, EISDIR with autodie, plus non-autodie control cases
  • t/autodie_sysopen_reverse.t — 6 tests: verifies import order (autodie before Test::MockFile) works via CHECK block caching

🤖 Generated with Claude Code

__sysopen had zero autodie integration while __open properly throws
autodie::exception at all failure points. When users had
`use autodie 'sysopen'`, failures would silently return false instead
of throwing exceptions.

Changes:
- Add _caller_has_autodie_for_sysopen() detection function
- Add _throw_autodie_sysopen() exception builder
- Throw autodie exceptions at all 6 failure points in __sysopen:
  O_NOFOLLOW/ELOOP, broken symlink/ENOENT, circular symlink/ELOOP,
  directory/EISDIR, O_EXCL/EEXIST, non-existent/ENOENT
- Update import() cache to also detect sysopen-specific autodie hints
- Add t/autodie_sysopen.t (9 subtests) and t/autodie_sysopen_reverse.t
  (3 subtests) covering both load orders

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@atoomic atoomic marked this pull request as ready for review February 28, 2026 01:01
@atoomic atoomic merged commit 818a1b6 into cpanel:master Feb 28, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants