Fix double-logo bug: only replace placeholder with logo image - #167
Open
sidharth-pardeshi wants to merge 5 commits into
Open
Fix double-logo bug: only replace placeholder with logo image#167sidharth-pardeshi wants to merge 5 commits into
sidharth-pardeshi wants to merge 5 commits into
Conversation
… image
When promo messages contain multiple instances of "Affirm" (e.g., "...with
Affirm. Affirm is a form of credit..."), ALL instances were being replaced
with logo images. Only the {affirm_logo} placeholder should become a logo;
plain text "Affirm" should remain as text.
Root cause: PromoRequest replaced the {affirm_logo} placeholder with plain
text "affirm", then AffirmUtils used a case-insensitive regex (\baffirm\b)
to replace every occurrence with a logo ImageSpan.
Fix: Keep the {affirm_logo} placeholder intact through the pipeline and
change LOGO_PATTERN to match the placeholder literal instead of the word
"affirm". The plain-text description still replaces the placeholder with
"Affirm" for accessibility/content description use.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Affirm-Skill: att-test
Affirm-Skill: buildkite-debug
Affirm-Skill: capture-context
Affirm-Skill: cmt-writer
Affirm-Skill: commit-and-push
Affirm-Skill: gather-best-practices
Affirm-Skill: mcp-debug
Affirm-Skill: save-output
Affirm-Skill: tickets-from-plan
Affirm-Skill: write-implementation-plan
…le inflation The new createSpannable tests were failing with Resources$NotFoundException because Robolectric cannot reliably inflate vector XML drawables. Replace RuntimeEnvironment.getApplication() with a mock Context that provides a mock Drawable via Resources.getDrawable(), so the tests verify spannable logic without depending on Android resource inflation. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Affirm-Skill: att-test Affirm-Skill: buildkite-debug Affirm-Skill: capture-context Affirm-Skill: cmt-writer Affirm-Skill: commit-and-push Affirm-Skill: gather-best-practices Affirm-Skill: generateReleaseUnitTestStubRFile Affirm-Skill: mcp-debug Affirm-Skill: save-output Affirm-Skill: testDebugUnitTest Affirm-Skill: tickets-from-plan Affirm-Skill: write-implementation-plan
When display type is TEXT (no logo), the {affirm_logo} placeholder was
leaking through as raw text. Now getSpannable replaces the placeholder
with "Affirm" when logoDrawable is null. Also adds test assertion to
verify the placeholder is not visible in TEXT display output.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Affirm-Skill: att-test
Affirm-Skill: buildkite-debug
Affirm-Skill: capture-context
Affirm-Skill: cmt-writer
Affirm-Skill: commit-and-push
Affirm-Skill: gather-best-practices
Affirm-Skill: generateReleaseUnitTestStubRFile
Affirm-Skill: mcp-debug
Affirm-Skill: save-output
Affirm-Skill: testDebugUnitTest
Affirm-Skill: tickets-from-plan
Affirm-Skill: write-implementation-plan
Match the Kotlin sample by using Y8CQXFF044903JC0 instead of 3HCWTVU5BYWZB9RK which is no longer responding. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Affirm-Skill: att-test Affirm-Skill: buildkite-debug Affirm-Skill: capture-context Affirm-Skill: cmt-writer Affirm-Skill: commit-and-push Affirm-Skill: gather-best-practices Affirm-Skill: generateReleaseUnitTestStubRFile Affirm-Skill: mcp-debug Affirm-Skill: save-output Affirm-Skill: testDebugUnitTest Affirm-Skill: tickets-from-plan Affirm-Skill: write-implementation-plan
wangdaliu
approved these changes
Apr 29, 2026
|
|
||
| private static final Pattern LOGO_PATTERN = | ||
| Pattern.compile("\\baffirm\\b", Pattern.CASE_INSENSITIVE); | ||
| Pattern.compile("\\{affirm_logo\\}"); |
Contributor
There was a problem hiding this comment.
This works as is, but using Pattern.quote would make it easier to maintain.
Pattern.compile(Pattern.quote(LOGO_PLACEHOLDER))
Collaborator
Author
There was a problem hiding this comment.
Done in 0026a93. Switched to Pattern.compile(Pattern.quote(LOGO_PLACEHOLDER)) and added the static import for LOGO_PLACEHOLDER from AffirmConstants.
Addresses review feedback: keeps the regex in sync with the LOGO_PLACEHOLDER constant so any future change to the placeholder string flows through automatically. Affirm-Skill: att-test Affirm-Skill: buildkite-debug Affirm-Skill: capture-context Affirm-Skill: cmt-writer Affirm-Skill: commit-and-push Affirm-Skill: gather-best-practices Affirm-Skill: mcp-debug Affirm-Skill: save-output Affirm-Skill: tickets-from-plan Affirm-Skill: write-implementation-plan
lrt98802
approved these changes
Apr 30, 2026
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.
Summary
Fix bug where ALL instances of "Affirm" in promo messages were replaced with logo images. Only the
{affirm_logo}placeholder positions should become logos; plain-text "Affirm" (e.g., in "Affirm is a form of credit") stays as text.Root Cause
PromoRequest.javareplaced{affirm_logo}with literal"affirm", losing the distinction between placeholder and real textAffirmUtils.javaused\baffirm\bregex pattern which matched EVERY "affirm" and replaced it with a logo ImageSpanChanges
AffirmUtils.java: Changed LOGO_PATTERN to match{affirm_logo}instead of\baffirm\bPromoRequest.java: Stopped converting placeholder to bare "affirm" before spannable rendering; placeholder now flows through intactAffirmUtilsTest.java: Added 4 regression testsTest plan
{affirm_logo}and plain "Affirm" -> only 1 logo