Skip to content

Filter non-transaction webhooks to prevent invalid API calls - #2

Closed
Billos with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-webhook-error-handling
Closed

Filter non-transaction webhooks to prevent invalid API calls#2
Billos with Copilot wants to merge 4 commits into
mainfrom
copilot/fix-webhook-error-handling

Conversation

Copilot AI commented Jan 8, 2026

Copy link
Copy Markdown
Contributor

Budget update webhooks were causing "Page not found" errors because the handler attempted to fetch them as transactions (e.g., budget ID 182 treated as transaction ID 182).

Changes

  • Filter webhook triggers: Only process STORE_TRANSACTION, UPDATE_TRANSACTION, and DESTROY_TRANSACTION. Ignore and log all other trigger types.
  • Remove build artifacts: Add build/ to .gitignore to prevent committing compiled output.
// Before: all webhooks processed as transactions
const body: WebhookTransactionBody = req.body
const queue = await getQueue()
for (const { id } of queues) {
  queue.add(id, { job: id, transactionId: `${body.content.id}` })
}

// After: filter by trigger type
const transactionTriggers = [
  WebhookTrigger.STORE_TRANSACTION,
  WebhookTrigger.UPDATE_TRANSACTION,
  WebhookTrigger.DESTROY_TRANSACTION,
]

const isSupportedTrigger = transactionTriggers.some(trigger => trigger === body.trigger)
if (!isSupportedTrigger) {
  console.log(`Ignoring non-transaction webhook trigger: ${body.trigger}`)
  res.send("<script>window.close()</script>")
  return
}
Original prompt

When I update the value of a budget (id 182 for instance) in Firefly, the webhook is called, and I'm getting this error :
2026-01-07T08:36:56.292499907Z =================================== Transaction webhook ===================================
2026-01-07T08:36:56.294130734Z Creating a new message for unbudgeted transaction with key 182
2026-01-07T08:36:56.386115571Z Job 17 failed with error Page not found
2026-01-07T08:36:56.387901399Z Creating a new message for uncategorized transaction with key 182
2026-01-07T08:36:56.423073579Z Job 18 failed with error Page not found


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@coderabbitai

coderabbitai Bot commented Jan 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copilot AI and others added 3 commits January 8, 2026 09:00
- Add check to only process transaction-related webhooks (STORE_TRANSACTION, UPDATE_TRANSACTION, DESTROY_TRANSACTION)
- Ignore budget-related webhooks (UPDATE_BUDGET, etc.) that were causing "Page not found" errors
- Log ignored webhook triggers for debugging

Co-authored-by: Billos <5809662+Billos@users.noreply.github.com>
Co-authored-by: Billos <5809662+Billos@users.noreply.github.com>
- Update console log message from "Transaction webhook" to "Webhook handler"
- Replace type assertion with safer comparison using .some() method
- Improve trigger validation to avoid type casting issues

Co-authored-by: Billos <5809662+Billos@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix webhook error handling for budget updates Filter non-transaction webhooks to prevent invalid API calls Jan 8, 2026
Copilot AI requested a review from Billos January 8, 2026 09:08
@Billos Billos closed this Jan 8, 2026
@Billos
Billos deleted the copilot/fix-webhook-error-handling branch January 8, 2026 12:30
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