Skip to content
This repository was archived by the owner on Apr 24, 2026. It is now read-only.

fix(edge): fix loop detector argument shift, infinite loops, and shadow mode suppression#156

Open
levleontiev wants to merge 1 commit into
mainfrom
fix/loop-detector-mismatches
Open

fix(edge): fix loop detector argument shift, infinite loops, and shadow mode suppression#156
levleontiev wants to merge 1 commit into
mainfrom
fix/loop-detector-mismatches

Conversation

@levleontiev
Copy link
Copy Markdown
Contributor

Summary

This PR fixes several bugs in the loop detection logic of fairvisor/edge:

  1. Argument Shift in rule_engine.lua: The _call wrapper expects (func, default_value, ...). It was called without a default_value, causing all arguments passed to build_fingerprint to be shifted by one (e.g., method received path). Fixed by adding 0 as the default value.
  2. Infinite Loops in loop_detector.lua: Table clearing using while #t > 0 do t[#t] = nil end is unsafe in Lua for certain scenarios. Replaced with proper for loops.
  3. Shadow Mode Suppression: Loop detection was rejecting requests even in shadow mode. Added _wrap_shadow call to ensure shadow policies only report but do not block loops.
  4. Nil Pointer in _build_decision_from_loop: Added a safety check for loop_result.action to prevent crashes when the action is missing.
  5. Undefined Variable: Fixed a bug where values was used instead of kv in _append_sorted_key_values.

Testing

  • Verified with a reproduction script that path|method are correctly included in the fingerprint and shadow mode correctly suppresses the rejection.
  • All 654 unit tests passed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants