fix: bq dataset ingest worker didnt start because of temporal lib issue (CM-1227)#4208
Conversation
Signed-off-by: Uroš Marolt <uros@marolt.me>
There was a problem hiding this comment.
Pull request overview
This PR addresses multiple production issues in the bq-dataset-ingest flow inside packages_worker, focusing on getting the worker to start reliably (Temporal client config / bundling) and to run successfully (BQ export ceilings and scorecard ingest robustness).
Changes:
- Updates
triggerBootstrapto use the shared@crowd/temporalclient/config instead of direct non-TLS Temporal connection wiring. - Improves scorecard ingest robustness (retries on merge activity, reduced write volume, and de-duping of scorecard checks staging rows).
- Adds runtime-configurable BQ dry-run byte ceilings via env overrides and documents how to run/operate the pipeline.
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| services/apps/packages_worker/src/scripts/triggerBootstrap.ts | Switches Temporal connection logic to @crowd/temporal client/config. |
| services/apps/packages_worker/src/scorecard/workflows/ingestScorecard.ts | Adds merge retries, reduces unnecessary updates, and de-dupes scorecard checks before upsert. |
| services/apps/packages_worker/src/scorecard/queries/scorecardSql.ts | Inlines the Scorecard BigQuery table reference to avoid importing config that drags SDKs into workflow bundling. |
| services/apps/packages_worker/src/deps-dev/workflows/ingestDependencies.ts | Raises the default BigQuery ceiling for package_dependencies. |
| services/apps/packages_worker/src/deps-dev/README.md | New operational/runbook-style documentation for the ingest pipeline and env overrides. |
| services/apps/packages_worker/src/deps-dev/activities/bqExportToGcs.ts | Adds per-kind env var overrides for the BQ dry-run ceiling. |
| services/apps/packages_worker/package.json | Cleans up scripts and adds helper scripts for triggering/monitoring. |
| pnpm-lock.yaml | Adds the workspace link for @crowd/temporal. |
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Uroš Marolt <uros@marolt.me>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4c01afe. Configure here.
Signed-off-by: Uroš Marolt <uros@marolt.me>

Summary
Fixes several bugs that prevented the
bq-dataset-ingestworker from starting and running successfully in production. The worker was crash-looping on boot due to a webpack bundling error, and subsequent runs hit GCS permission errors, Temporal connection failures, and BQ byte-ceilingmisconfigurations.
Changes
scorecardSql.tsimportedSCORECARD_DATASETfromconfig.ts, which instantiates BigQuery/Storage clients at module load — dragging the SDK into the Temporal workflow sandbox bundle and failing onnode:util/node:zlib. Inlined the dataset string literal tomatch the existing pattern in
deps-dev/queries/*.tstriggerBootstrap.ts: Script was using a plain non-TLS connection and reading the wrong namespace (CROWD_TEMPORAL_NAMESPACE= main CDP namespace instead of packages namespace). Replaced withgetTemporalClient()+TEMPORAL_CONFIG()from@crowd/temporalwhich handles mTLS correctly
CROWD_TEMPORAL_NAMESPACE=$CROWD_PACKAGES_TEMPORAL_NAMESPACEinline overrides from allstart:/dev:scripts — k8s manifests now overrideCROWD_TEMPORAL_NAMESPACEdirectly. Addedtrigger-bootstrap,trigger-bootstrap:local,monitor:osspckgs,monitor:osspckgs:localnpm scripts. Fixedmonitor:osspckgsto point tosrc/scripts/monitorOsspckgs.tsinstead of deleted.mjsfileBQ_DATASET_INGEST_<KIND>_MAX_BQ_GBenv vars. Bumpedpackage_dependenciesceiling 3000→10000 (incremental always scans ~2 full-day partitions, ~3.85TB by design),scorecard_repos10→50,scorecard_checks200→500mergeStagingToTablehadmaximumAttempts: 1— a deadlock from a concurrent writer (github-repos-enricher) caused instant workflow failure. Bumped to 3 retries with 30s backoff. AddedORDER BY repo_urlto the repos merge to enforce consistent lock order. Addedskip-unchanged filter to reduce rows written
(repo_url, check_name)rows →ON CONFLICT DO UPDATE command cannot affect row a second time. Fixed withDISTINCT ON (repo_url, check_name)in the INSERT SELECT@crowd/temporaldep topackages_workersrc/deps-dev/README.mddocumenting all BQ ceiling overrides, env vars, and how to run/triggerType of change
JIRA ticket
https://linuxfoundation.atlassian.net/browse/CM-1227
Note
Medium Risk
Touches production ingest (Temporal, BigQuery billing ceilings, and Postgres merge behavior); changes are targeted bug fixes but misconfigured ceilings or merge logic could still fail or over-bill runs.
Overview
Restores
bq-dataset-ingestso the worker can start and complete scorecard/deps exports in prod.Workflow bundle / boot:
scorecardSql.tsno longer importsdeps-dev/config(which pulled BigQuery/Storage into the Temporal workflow sandbox). OpenSSF tables are referenced with a literal`openssf.scorecardcron.scorecard-v2_latest`string instead.Temporal ops:
triggerBootstrap.tsuses@crowd/temporal(TEMPORAL_CONFIG,getTemporalClient) for mTLS and namespace config. npmstart:/dev:scripts drop inlineCROWD_PACKAGES_TEMPORAL_NAMESPACEoverrides; newtrigger-bootstrapandmonitor:osspckgsscripts replace the old monitor.mjspath.BQ cost guards:
bqExportToGcshonorsBQ_DATASET_INGEST_<KIND>[_<MODE>]_MAX_BQ_GBenv overrides (documented insrc/deps-dev/README.md). Default ceilings rise forpackage_dependencies(10TB),scorecard_repos, andscorecard_checks.Scorecard Postgres merges:
mergeStagingToTableretries increase (3× with backoff). Repos merge usesORDER BY repo_url, skips unchanged rows, and checks merge usesDISTINCT ON (repo_url, check_name)to avoid duplicate-key failures from BQ dupes and deadlocks with concurrent writers.Reviewed by Cursor Bugbot for commit 8a77284. Bugbot is set up for automated code reviews on this repo. Configure here.