Skip to content

fix(dynamic-images): find the contact by its id when rendering - #1827

Merged
sung17 merged 1 commit into
mainfrom
fix/dynamic-image-contact-lookup
Nov 30, 2026
Merged

sung17 merged 1 commit into
mainfrom
fix/dynamic-image-contact-lookup

Conversation

@sung17

@sung17 sung17 commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator

Problem

A dynamic image sent through a flow showed only the template picture. Every other layer was missing: text (plain and {{variable}}), avatar or custom-field images, and QR codes.

Since #1071, flows fill the link's {{user_id}} with the contact's own id (Contact.id). The /dynamic-images route still looked that value up as the channel-side ContactInbox.sourceId, so no contact ever matched. The route then fell back to the static background. That background holds only the leading run of static layers, which is usually just the template, because every layer after the first dynamic one is drawn per contact.

Fix

  • New dynamicImageService.resolveContactInbox({ workspaceId, userId }). It looks up the contact by Contact.id first (only for ids within the Postgres bigint range), then falls back to sourceId so links sent before fix(variables): resolve user_id system field to the contact id #1071 keep working.
  • The route uses the new method. The comment that described userId as the channel id is corrected.
  • The public API imageUrl description now says {{user_id}} is the contact's id.

Tests

  • packages/business/__tests__/dynamic-image-resolve-contact.test.ts: lookup by contact id, fallback to source id, non-numeric and out-of-range ids, no match.
  • apps/builder/__tests__/dynamic-images-route.test.ts: renders for a matched contact; serves the background when none matches.
  • pnpm lint, builder and business check-types, and the dynamic-image and public-spec tests all pass.

🤖 Generated with Claude Code

Flows fill a dynamic image link's {{user_id}} with the contact's own id
(Contact.id) since #1071, but the /dynamic-images route still looked it up
as the channel-side ContactInbox.sourceId. No contact ever matched, so every
send fell back to the static background and showed only the leading static
layers (usually just the template picture).

The route now resolves the contact through
dynamicImageService.resolveContactInbox: by Contact.id first, then by
sourceId for links sent before the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions github-actions Bot added the bug Something isn't working as expected label Nov 30, 2026
@sung17
sung17 merged commit bdc396b into main Nov 30, 2026
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working as expected

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant