Skip to content

fix: use the nearest day's price for trigger <value> when the day's is missing - #1176

Open
Klakurka wants to merge 1 commit into
masterfrom
ccr-b62297cf-awgd35-trigger-missing-price
Open

Klakurka wants to merge 1 commit into
masterfrom
ccr-b62297cf-awgd35-trigger-missing-price

Conversation

@Klakurka

@Klakurka Klakurka commented Dec 3, 2026

Copy link
Copy Markdown
Member

Related to #1062

Description

Payment triggers whose POST data includes the payment's value (<value>) still failed when we had no price for the day of the payment. This happens most often right after midnight (UTC), before the new day's price is available.

Now, when the day's price is missing, the trigger uses the price from the nearest day we have, up to 3 days before or after, so it fires anyway. If no price is that close, the trigger fails and is logged as before. Emails and POST triggers that don't use <value> were already fixed in 94d7bea and still fire.

Test plan

  • make github-test-unit: all 19 suites / 410 tests pass. New unit tests:
    • priceService: the nearest-price lookup searches both sides of the day within the window and ignores the current-price row. It picks the closest day (the earlier one on a tie), takes USD and CAD from the same day, and errors when nothing is found.
    • triggerService: <value> is filled from the fallback price when the day's price is missing. The fallback is not used when the day's price exists. When no price is found at all, the <value> trigger is logged as an error and the other triggers still run.
  • npx tsc --noEmit -p .: no new errors in the changed files (the repo has pre-existing errors elsewhere).
  • eslint on the changed files: clean.

Remarks


Generated by Claude Code

…s missing

Payment triggers whose post data uses <value> failed when the tx's day had no
price yet, e.g. for payments right after midnight UTC, before the new day's
price is available from the price API.

When that day's prices can't be found or fetched, look up those of the nearest
day that has them (at most TRIGGER_PRICE_FALLBACK_MAX_DAYS = 3 days away, same
day for USD and CAD, current price row excluded) and log which day was used.
Only the trigger value uses the fallback; the tx itself is still linked to
its own day's prices once they are available.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019G564i2sNiHJYQR95m8zGq
@coderabbitai

coderabbitai Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 56 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 78917e09-00da-4570-bf2a-80c5e5305ac0
Commits

Reviewing files that changed from the base of the PR and between f9d06f2 and 51435b4.

Files selected for processing: 5

  • constants/index.ts
  • services/priceService.ts
  • services/triggerService.ts
  • tests/unittests/priceService.test.ts
  • tests/unittests/triggerService.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants