Skip to content

fix(den): create config object versions on github connector push#2003

Merged
src-opn merged 2 commits into
devfrom
check-github-update-connector-instance-item
May 29, 2026
Merged

fix(den): create config object versions on github connector push#2003
src-opn merged 2 commits into
devfrom
check-github-update-connector-instance-item

Conversation

@src-opn
Copy link
Copy Markdown
Collaborator

@src-opn src-opn commented May 29, 2026

Summary

When a user has the GitHub integration connected and a repo configured into a marketplace/plugin/config item, a push to that repo correctly recorded a connector_sync_event but never created a new config_object_version. This PR fixes the sync chain and adds rich outcome data to the event.

Root cause

The webhook → enqueueGithubWebhookSyncmaybeAutoImportGithubConnectorInstanceapplyGithubConnectorDiscoverymaterializeGithubImportedObject chain had three issues:

  1. Stale discovery cache (primary bug). resolveGithubConnectorDiscovery returned the cached snapshot whenever branch/ref/repo matched — always true across pushes to the same branch — so it reused the previous sourceRevisionRef. The version guard binding.lastSeenSourceRevisionRef !== input.sourceRevisionRef then saw an unchanged revision and skipped the version insert.
  2. Auto-import gate too strict. The gate required autoImportNewPlugins === true, diverging from getGithubDiscoveryContext which defaults an unset flag to enabled.
  3. Silently swallowed errors. The catch discarded the error with no log and no record, so a failed sync looked identical to a benign queued.

Changes

  • Add forceRefresh to resolveGithubConnectorDiscovery / applyGithubConnectorDiscovery; the webhook auto-import path forces a fresh discovery so the latest head revision and files are fetched → new version created on push.
  • Treat an unset autoImportNewPlugins as enabled (!== false) so already-configured repos re-sync unless explicitly opted out.
  • Capture auto-import errors: console.error them and record status: "failed" with the message in summary_json.error.
  • Link config_object_version.connectorSyncEventId to the triggering sync event (FK existed in schema but was always written null).
  • Enrich summary_json with full outcome data: outcome, error, classification, resolvedSourceRevisionRef, discoveredPluginCount, createdMarketplace, createdPlugins, materializedConfigObjects (id/type/path/title/versionId), and timing (startedAt/completedAt/durationMs).
  • New status semantics: completed only when a version is materialized, partial when auto-import ran cleanly but produced no version, failed on error, queued when import didn't run.

Tests run

  • pnpm exec tsc --noEmit -p tsconfig.json (den-api) — clean
  • bun test test/github-webhook.test.ts test/github-discovery.test.ts test/github-connector-app.test.ts12 pass / 0 fail

Note: the full webhook → DB round-trip tests require a live MySQL, which was not available in this environment, so they were not run. To reproduce end-to-end: bring up MySQL, seed a GitHub connector instance/target bound to a repo, push to the linked branch, and confirm a new config_object_version row appears with connectorSyncEventId set and the enriched summary_json. I was not able to capture a video for the same reason.

Files

  • ee/apps/den-api/src/routes/org/plugin-system/store.ts

The GitHub connector webhook recorded a connector_sync_event but never
produced a new config_object_version on push. Three issues:

- Discovery was served from a stale cache keyed on branch/ref/repo, so
  pushes reused the previous sourceRevisionRef and the version guard in
  materializeGithubImportedObject skipped creating a version. Auto-import
  now forces a fresh discovery so the latest head revision/files are used.
- The auto-import gate required autoImportNewPlugins === true, diverging
  from getGithubDiscoveryContext defaults; an unset flag now resolves to
  enabled so already-configured repos re-sync unless explicitly opted out.
- Errors from auto-import were swallowed silently; they are now logged and
  recorded on the sync event (status "failed" with the message).

Also link config_object_version.connectorSyncEventId to the triggering
sync event, and enrich summary_json with full outcome data (outcome,
error, classification, resolved revision, created plugins/marketplace,
materialized config objects, and timing). Status is "completed" only when
a version is materialized, otherwise "partial".
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 29, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
openwork-app Ready Ready Preview, Comment May 29, 2026 2:54pm
openwork-den Ready Ready Preview, Comment May 29, 2026 2:54pm
openwork-den-worker-proxy Ready Ready Preview, Comment May 29, 2026 2:54pm
openwork-landing Ready Ready Preview, Comment, Open in v0 May 29, 2026 2:54pm

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread ee/apps/den-api/src/routes/org/plugin-system/store.ts
Restore the early return in maybeAutoImportGithubConnectorInstance so a
connector instance with autoImportNewPlugins explicitly set to false does
not run discovery or materialize config objects. The sync event is
recorded with status "ignored". (Reported by cubic.)
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.

1 participant