INNER CODE UNIT · Python
_lock_field_refusal
IvanMurzak/Unity-MCP · .github/scripts/chain_feed.py:723
def _lock_field_refusal(where, value, shape):
# `%r` escapes CR/LF and quotes the value, so the refusal line itself cannot be split.
return Refusal("lock %s = %r is not %s; refusing the whole lock before any value is used" % (where, value, shape))
def _lock_string(where, value):
if not isinstance(value, str):
raise _lock_field_refusal(where, value, "a string")
if _CONTROL_CHARS_RE.search(value):
raise _lock_field_refusal(where, value, "free of control characters (CR, LF, NUL, ...)")
return value
def validate_lock(lock):
"""Refuse (exit 2) any lock whose scalars are not exactly the shape `lock.py` writes.
Runs in `build_context` straight after the JSON parse, BEFORE the lock hash, the node's sha,
the recipes or any writer reads a value — so a value that would change a shell command, a