Current state
| Malformed field |
Behaviour |
Invalid regex in patterns |
That pattern is skipped, rule still loads |
Unrecognised action |
That rule is skipped, file still loads |
keywords: null |
Normalised to an empty list, rule still loads |
patterns: null |
Uncaught TypeError aborts loading of the entire guardrails.yml |
The failure originates at platform/guardrails/rules.py#L93,
where raw.get("patterns", []) returns None because the default applies only to an
absent key, not to a present key with an empty value.
The blast radius is wider than one file failing to parse. Nothing guards the call:
the only try/except in _parse_rule is the except re.error around re.compile,
which is never entered because the exception fires while evaluating the iterable, and
load_rules's own handler wraps yaml.safe_load, which has already completed by
then. All three callers invoke load_rules() bare. Because the exception propagates
before _engine is assigned, get_guardrail_engine() raises again on every
subsequent call rather than failing once.
Desired state
| Malformed field |
Behaviour |
patterns: null |
The rule is skipped and the reason is logged |
patterns set to a non-list type |
The rule is skipped and the reason is logged |
| Any other rule in the file |
Unaffected, loading continues |
The obvious fix is raw.get("patterns") or [], matching the keywords handling two
lines below.
Current state
patternsactionkeywords: nullpatterns: nullTypeErroraborts loading of the entireguardrails.ymlThe failure originates at
platform/guardrails/rules.py#L93,where
raw.get("patterns", [])returnsNonebecause the default applies only to anabsent key, not to a present key with an empty value.
The blast radius is wider than one file failing to parse. Nothing guards the call:
the only
try/exceptin_parse_ruleis theexcept re.erroraroundre.compile,which is never entered because the exception fires while evaluating the iterable, and
load_rules's own handler wrapsyaml.safe_load, which has already completed bythen. All three callers invoke
load_rules()bare. Because the exception propagatesbefore
_engineis assigned,get_guardrail_engine()raises again on everysubsequent call rather than failing once.
Desired state
patterns: nullpatternsset to a non-list typeThe obvious fix is
raw.get("patterns") or [], matching thekeywordshandling twolines below.