Skip to content

fix(passkey-email): mark unrendered Browser/Device variables optional - #86

Merged
yahyafakhroji merged 1 commit into
mainfrom
fix/passkey-email-empty-browser-device
Jul 30, 2026
Merged

fix(passkey-email): mark unrendered Browser/Device variables optional#86
yahyafakhroji merged 1 commit into
mainfrom
fix/passkey-email-empty-browser-device

Conversation

@yahyafakhroji

@yahyafakhroji yahyafakhroji commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

The PR #82 fix (dropping the empty Browser/Device rows) merged and published fine, but staging never applied it: the Flux Kustomization datum-email-templates-customization has been in ReconciliationFailed since Jul 29, pinned to the Jul 24 bundle (v0.0.0-main-20260724-023346) — which is why staging emails still show the empty rows.

Root cause: milo's EmailTemplate admission webhook requires every required: true variable to be referenced in both htmlBody and textBody (pkg/email/templating/{html,text}validator.go). PR #82 removed the {{.Browser}}/{{.Device}} references, but scripts/generate-yaml.js hardcodes required: true for every PreviewProps key — so milo rejects the new template and Flux retries forever on the old bundle. Invisible in CI, since the webhook only runs at apply time in-cluster.

Fix: the generator now derives each variable's required flag from whether the rendered html/text output actually references it. Declared-but-unrendered variables (kept declared because producers still send them, and undeclared sent variables are rejected at send time) are emitted as required: false, which milo accepts. This makes the "webhook rejects bundle, Flux silently stuck" failure class impossible by construction.

Bundle diff is exactly the fix: only Browser/Device flip to required: false in userpasskeyadded-emailtemplate.yaml; all other templates are byte-identical.

Test plan

  • pnpm generate:all with lockfile-pinned deps — only the passkey YAML variables change
  • Replicated milo's webhook validation (same regexp, same both-bodies rule) against the bundle: current main's passkey YAML fails exactly as staging rejects it; this branch's passes, all 8 templates green
  • After merge: confirm datum-email-templates-customization becomes Ready and its revision advances to the new v0.0.0-main-* tag (OCIRepository polls every 5m, failing Kustomization retries every 2m)
  • Trigger a passkey-added email on staging and confirm the Browser/Device rows are gone

Related

milo's EmailTemplate admission webhook rejects any template whose
required variable is not referenced in both htmlBody and textBody.
The passkey template declares Browser and Device (producers still send
them) but no longer renders them, so staging's Flux apply of the fixed
bundle has been failing since Jul 29 and staging stayed pinned to the
Jul 24 bundle that still shows the empty rows.

generate-yaml.js now derives each variable's required flag from whether
the rendered html/text output actually references it, so the bundle
stays acceptable to milo by construction.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NWH7RtwJ1b4Dz3WyJXQTCD
@yahyafakhroji
yahyafakhroji requested review from a team as code owners July 30, 2026 13:01
@yahyafakhroji yahyafakhroji added the ai-assisted Authored with AI assistance (Claude Code) label Jul 30, 2026
@yahyafakhroji
yahyafakhroji requested a review from ecv July 30, 2026 13:01
@yahyafakhroji yahyafakhroji removed the ai-assisted Authored with AI assistance (Claude Code) label Jul 30, 2026
@yahyafakhroji yahyafakhroji self-assigned this Jul 30, 2026
@yahyafakhroji yahyafakhroji added the ai-assisted Authored with AI assistance (Claude Code) label Jul 30, 2026
@yahyafakhroji
yahyafakhroji merged commit 0978546 into main Jul 30, 2026
6 checks passed
@yahyafakhroji
yahyafakhroji deleted the fix/passkey-email-empty-browser-device branch July 30, 2026 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai-assisted Authored with AI assistance (Claude Code)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants