Skip to content

Commit 5dc1ee6

Browse files
fix(validator): detect name= in single-line pedigree assignment (#20)
Why: developer-ecosystem@baab1534 revealed that `pedigree = component_pedigree & { name = "..." }` written on a single line was not detected by the validator. The `name =` check used `^[[:space:]]+name[[:space:]]*=` which requires name to start a line with leading whitespace. On a single-line pedigree the opening and closing braces appear on the same line as `pedigree =`, so pedigree_depth returns to 0 immediately and subsequent line-iteration never has a chance to see `name =` on a freshly-indented line. Change (option b — parse the whole logical unit): the `name =` and `version|schema_version =` checks now carry a second condition using the unanchored pattern `[[:space:]]name[[:space:]]*=` which matches the inline form. The existing anchored check is kept for the normal multi-line case. Both checks are guarded by `in_pedigree == true` so they only fire within the recognised pedigree block. Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9b0068f commit 5dc1ee6

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

validate-k9.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,25 @@ validate_k9() {
197197
:
198198
fi
199199

200-
# Check for name field within pedigree.metadata or pedigree directly
201-
if [[ "$line" =~ ^[[:space:]]+name[[:space:]]*= ]]; then
200+
# Check for name field within pedigree.metadata or pedigree directly.
201+
# Two patterns cover both multi-line and single-line pedigrees:
202+
# 1. ^[[:space:]]+name[[:space:]]*= — the normal multi-line case where
203+
# `name = "..."` appears on its own indented line.
204+
# 2. [[:space:]]name[[:space:]]*= — inline within a single-line
205+
# pedigree assignment such as:
206+
# pedigree = component_pedigree & { name = "foo" }
207+
# (root cause: developer-ecosystem@baab1534 — single-line form
208+
# was missed entirely because the pedigree block opened and
209+
# closed in one line, never reaching the ^[[:space:]]+ check on
210+
# a subsequent iteration.)
211+
if [[ "$line" =~ ^[[:space:]]+name[[:space:]]*= ]] || \
212+
[[ "$line" =~ [[:space:]]name[[:space:]]*= ]]; then
202213
has_pedigree_name=true
203214
fi
204215

205216
# Check for version field
206-
if [[ "$line" =~ ^[[:space:]]+(version|schema_version)[[:space:]]*= ]]; then
217+
if [[ "$line" =~ ^[[:space:]]+(version|schema_version)[[:space:]]*= ]] || \
218+
[[ "$line" =~ [[:space:]](version|schema_version)[[:space:]]*= ]]; then
207219
has_pedigree_version=true
208220
fi
209221

0 commit comments

Comments
 (0)