Extend tag field mapping to comma-strings and object arrays - #234
Open
grimicorn-agent wants to merge 4 commits into
Open
Extend tag field mapping to comma-strings and object arrays#234grimicorn-agent wants to merge 4 commits into
grimicorn-agent wants to merge 4 commits into
Conversation
Collaborator
Author
Independent code review trailRan the independent reviewer (Opus) over Round 1 — flagged:
Round 2 — flagged:
Round 3 — flagged:
Deferred / not actioned (with reason):
Final: |
Collaborator
Author
Agent code review trailMerged Round 1 — flagged:
Round 2 — flagged:
Round 3 — flagged:
Unresolved after 3 rounds (follow-ups, not blockers):
Verification: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What & why
server/utils/fieldMapper.tspickTagsFieldonly accepted an array of plain strings, so the two most common real webhook tag shapes silently produced no tags: a comma-delimited string, and an array of objects like GitHub'slabels[].name. This made tags mapping unusable for those providers (#228).pickTagsFieldnow accepts, via a sharedcoerceTagsValuehelper:,, trimmed, empties dropped.name,title,label,value(GitHub labels →name).Anything else (number, boolean, plain object, etc.) still yields
undefined.Decisions
buildRawWebhookPayload(the raw, unmapped passthrough) now routes through the samecoerceTagsValue, so an identical payload produces identical tags whether or not afieldMappingis configured. Previously the two paths diverged (raw path only filtered non-strings).toNonEmptyTaghelper (rule of three: comma-split, object-key, and bare-string paths all share it).hasOwnProperty), matching the existinggetNestedValueprototype-safety posture, so an inheritedname/titleonObject.prototypecan't fabricate a tag.["a,b"]stays one tag). Pinned by a test.Tests
31 tests in
tests/server/utils/fieldMapper.test.tscovering: array of strings, comma string (top-level and nested path), array of objects (nameand fallback keys, priority order,labelkey), empty array, blank/whitespace items, non-string priority key fall-through, garbage input, and the raw-path (buildRawWebhookPayload) coercion.Viewable
Webhook ingest path —
server/api/hooks/[slug].post.ts→applyFieldMapping. No UI surface; behavior is verified by the unit tests above.Closes #228
Follow-up suggestions
Cap tag count and per-tag length— A string field mapped (or misconfigured) totagsexpands an arbitrarily large comma body into unbounded tags that flow straight intorecords.tagsjsonb and one YAML frontmatter line; add namedMAX_TAGS/MAX_TAG_LENGTHlimits incoerceTagsValue(suggested: P3, effort: S, evidence: server/utils/fieldMapper.ts coerceTagsValue)Dedupe extracted tags— Comma strings and object arrays can now easily yield duplicate tags ("bug, bug",[{name:"bug"},{name:"bug"}]) that persist and render astags: [bug, bug]; consider order-preserving de-duplication incoerceTagsValue(suggested: P4, effort: S, evidence: server/utils/fieldMapper.ts coerceTagsValue)