Skip to content

docs: correct plugin failure-classification comment in authorizer - #119

Open
alberto-crossmint wants to merge 1 commit into
mainfrom
docs/plugin-failure-classification
Open

docs: correct plugin failure-classification comment in authorizer#119
alberto-crossmint wants to merge 1 commit into
mainfrom
docs/plugin-failure-classification

Conversation

@alberto-crossmint

Copy link
Copy Markdown
Collaborator

Summary

The inline comment next to the Err(Err(_)) arm in authorizer.rs::call_plugins_on_auth listed "panic!, host trap, TTL expiry" together in the fail-open branch. That is inaccurate on Soroban 22.

Actual classification, pinned by the new test:

Plugin outcome try_* shape Behaviour
normal return Ok(Ok(_)) continue
ABI return-type mismatch Ok(Err(_)) SKIP (fail-open)
contracterror / panic_with_error! / plain panic! / unwrap() / overflow Err(Ok(_)) REJECT (fail-closed)
host trap — archival, budget, missing code, stack overflow Err(Err(_)) SKIP (fail-open)

The practical implication: a buggy plugin that panics at runtime will block authorization (fail-closed) — it will not be silently bypassed. The fail-open path is environmental only.

This is a docs-only PR plus a regression test.

Changes

  • Rewrite the comment block above the match res { to match reality and to note explicitly that plain panic! and unwrap() are fail-closed.
  • Add test_plugin_plain_panic_is_fail_closed to plugin_test.rs — installs a plugin whose on_auth does panic!(...) and asserts __check_auth returns Err(Ok(Error::PluginOnAuthFailed)). Future Soroban runtime changes that alter this classification will surface here.

Test plan

  • test_plugin_plain_panic_is_fail_closed — plain panic! blocks auth.
  • Existing test_plugin_intentional_rejection_blocks_authpanic_with_error! also blocks auth (documents symmetry).
  • Existing test_uninstall_plugin_persists_removal and test_max_plugins_limit unaffected.

Why not also pin the fail-open branch?

Err(Err(_)) requires an actual host trap (archival, budget exhaustion, missing contract). Those are hard to simulate deterministically in a unit test without fixture setup proportional to the payoff, and the Soroban SDK doesn't expose a stable way to force them. The classification of the common branches is pinned; fail-open-under-trap is documented but not asserted.

The inline comment next to the Err(Err(_)) arm listed "panic!, host
trap, TTL expiry" together. That was inaccurate: on Soroban 22 a plain
`panic!` in a plugin produces Err(Ok(_)) (intentional rejection /
fail-closed), NOT Err(Err(_)) (host trap / fail-open). Only genuine
host traps — storage archival, budget exhaustion, contract not found,
stack overflow — reach the fail-open arm.

The inaccurate grouping risked misleading future maintainers into
thinking a buggy unwrap in a plugin would be silently bypassed.
It won't; it blocks auth like any intentional rejection.

No behaviour change. Only the comment is fixed, and a regression test
is added pinning the actual classification so future refactors must
preserve it.
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