Slack: Move run-creation notifications from Lambda to web app - #60
Merged
Conversation
The Lambda previously called slack.send_message once per file processed, which produced multiple "Finished preprocessing run X" messages per run even though the wording implied one. Notifications now fire from POST /api/v1/instruments/:instrumentId/runs when the upsert actually inserts a new row, so each run triggers exactly one Slack message regardless of how many files arrive (lambda or watcher). Adds web-app/lib/slack.ts (no-op when SLACK_WEBHOOK_URL is unset, swallows errors so a Slack outage cannot fail the API request) and an integration test using an in-process capture server. Removes data_hub_shared.slack, the SLACK_WEBHOOK_URL config field, the SlackWebhookUrl SAM parameter / Makefile / deploy-lambda.yml plumbing, the dead result_url return path from each per-instrument process_file, and the now-unused DATA_HUB_WEB_URL constant. Operators must set SLACK_WEBHOOK_URL in the Vercel environment (it is no longer needed in GitHub environment secrets or infra/.env.*). Co-authored-by: Cursor <cursoragent@cursor.com>
Contributor
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
Slack notifications previously fired once per file processed by the Lambda — producing multiple "Finished preprocessing run X" messages per run, which contradicted the wording. They now fire once per newly-created run, from the web app's
POST /api/v1/instruments/:instrumentId/runsendpoint, gated on theonConflictDoNothingupsert actually inserting a row.Changes
web-app/lib/slack.ts(sendSlackMessage) — readsSLACK_WEBHOOK_URL, no-ops when unset, swallows errors so a Slack outage cannot fail the API request.POST .../runsposts one Slack message perisNewinsert, usinginstruments.displayNameandnew URL(request.url).originfor the deep link.slack.send_message,INSTRUMENT_ID_TO_NAME_MAP, andget_cloudwatch_logs_urlare gone fromhandler.py. Per-instrumentprocess_filefunctions now returnNone(wasstr) andDATA_HUB_WEB_URL/lambda/src/data_hub_lambda/constants.pyare deleted.data_hub_shared.slackand theSLACK_WEBHOOK_URLfield ondata_hub_shared.configare removed;SlackWebhookUrlis dropped frominfra/template.yaml, theMakefile,deploy-lambda.yml, and theinfra/.env.*/lambda/.env.examplefiles.(instrument_id, run_id)POST captures exactly one Slack message. The capture infra is an in-process HTTP server intests/integration/global-setup.tsexposed viagetCapturedSlackMessages()/clearCapturedSlackMessages().lambda.md,architecture.md,shared-library.md,getting-started.md,ci-and-deployment.md,adding-an-instrument.md, and the rootREADME.md.Breaking changes
SLACK_WEBHOOK_URLmust be configured in Vercel per environment. It can be removed from the GitHubstaging/productionenvironment secrets and frominfra/.env.staging/infra/.env.production— leaving the latter in place will failsam deploybecause the SAM parameter no longer exists.data_hub_shared.slackmodule andconfig.SLACK_WEBHOOK_URLare gone; any external consumer would need to migrate (none exist in this repo).process_filereturn type changed fromstrtoNone.Driveby changes
result_urlassertions fromlambda/tests/epson_v700_scanner/test_process_file.py.process_filesignature.Testing
make check-allpasses locallyweb-app/tests/integration/instrument-runs.test.tspasses (duplicate POST → single Slack message)mock_slackfixture removedsam deploysucceeds after removingSlackWebhookUrlfrominfra/.env.staging/infra/.env.production