Skip to content

Comments

fix: prevent crash on unblessed references in Set::_isdq()#3

Closed
Koan-Bot wants to merge 3 commits intocern-mig:masterfrom
atoomic:koan.atoomic/fix-set-isdq-unblessed
Closed

fix: prevent crash on unblessed references in Set::_isdq()#3
Koan-Bot wants to merge 3 commits intocern-mig:masterfrom
atoomic:koan.atoomic/fix-set-isdq-unblessed

Conversation

@Koan-Bot
Copy link

Summary

Directory::Queue::Set crashed with "Can't call method 'isa' on unblessed reference" when passed an unblessed reference (hashref, arrayref, etc.) instead of producing the expected "not a Directory::Queue object" error message.

Root cause: _isdq() used ref($thing) && $thing->isa(...) — but ref() returns true for unblessed refs too, and ->isa() requires a blessed object.

Fix: Use Scalar::Util::blessed() (core module since Perl 5.8) instead of ref().

Changes

  • lib/Directory/Queue/Set.pm: Import Scalar::Util::blessed, use it in _isdq()
  • t/2set-validation.t: 5 new tests for various invalid inputs (hashref, arrayref, scalar ref, plain string)

Test plan

  • Unblessed hashref now produces "not a Directory::Queue object" error
  • Same for arrayref, scalar ref, plain string
  • add() method also properly validates
  • Full test suite passes (242 tests)

🤖 Generated with Claude Code

Nicolas Rochelemagne and others added 3 commits July 11, 2025 17:02
Fixup pod example
_isdq() called ->isa() on any reference, but unblessed references
(plain hashrefs, arrayrefs) cause "Can't call method 'isa' on
unblessed reference". Use Scalar::Util::blessed() to check before
calling ->isa(), producing the expected "not a Directory::Queue
object" error message.

Added tests for various non-DQ inputs (hashref, arrayref, scalar ref,
plain string).
@Koan-Bot
Copy link
Author

Superseded by #14 — clean branch with only the relevant fix (no fork infrastructure commits).

@Koan-Bot
Copy link
Author

Superseded by #14 (clean branch from upstream/master, no fork infrastructure noise).

@Koan-Bot Koan-Bot closed this Feb 21, 2026
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.

1 participant