fix(automations): resolve friendly template fields ({user_name}, {challenge_title}, …) - #33
Merged
Merged
Conversation
…allenge_title}, …
Event payloads carry raw ids, so a template like "{user_id} solved it"
rendered a UUID (#27). Before a matched rule's actions run, the engine now
resolves each id field into a human-friendly companion:
user_id → user_name team_id → team_name
opener/assignee/author/actor_user_id → *_user_name
challenge_id → challenge_title survey_id → survey_title
ticket_id → ticket_subject competition_id → competition_name
- FRIENDLY_FIELDS + enrich_payload in utils/automation_actions.py; invoked
once per rule run in run_rule — the single choke point both the engine and
the time-based scheduler pass through, so every template-rendering action
(notify / announcement / email / webhook body) sees the fields.
- Ids stay ids: webhooks and conditions legitimately need raw values, so the
friendly names are companions, not replacements. An id that no longer
resolves falls back to the raw value — an advertised placeholder never
renders as a literal {user_name}.
- The builder catalog derives the friendly fields per trigger from the same
map, so the rule editor suggests {user_name} & co. automatically.
- Enrichment is fail-open (a lookup error logs and the rule still runs).
Tests: enrich_payload unit (resolution, id fallback, non-mutation), run_rule
end-to-end (announcement body renders names, not UUIDs), catalog advertising.
Backend suite: 377 passed.
Fixes #27
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Fixes #27
Root cause
Event payloads carry raw ids, and
render_templatesubstitutes payload values verbatim — so{user_id}in an announcement body rendered a UUID.Fix — friendly companion fields
Before a matched rule's actions run, the engine resolves every id field in the payload into a human-friendly companion:
user_id(+opener/assignee/author/actor_user_id)user_name(+ matching*_user_name)team_idteam_namechallenge_idchallenge_titlesurvey_idsurvey_titleticket_idticket_subjectcompetition_idcompetition_namerun_rule— the single choke point both the engine and the time-based scheduler pass through, so every template-rendering action (notify / announcement / email / webhook body) sees them.{user_name}& co. appear in the field suggestions automatically.{user_id}still renders the id (webhook payloads and conditions legitimately need raw values). The friendly names are companions, not replacements — the builder's suggestions steer authors to the right placeholder.{user_name}. Enrichment is fail-open — a lookup error logs and the rule still runs.Verification
enrich_payloadunit (resolution, id fallback, input non-mutation),run_ruleend-to-end (announcement body rendersgrace drew first blood on Warmup., not UUIDs), catalog advertising per triggerFollow-up (after this + #31 merge)
The demo seed's first-blood announcement can then showcase this:
"{user_name} drew first blood on {challenge_title}!"— which also makes successive demo announcements visibly distinct (the perception half of #19). Kept out of this PR to avoid a demo.py conflict with #31.🤖 Generated with Claude Code