Skip to content

feat: issue subgraph check extensions for proposals#2615

Merged
wilsonrivera merged 8 commits intomainfrom
wilson/eng-9071-investigation-missing-check-extensions-on-proposal
Mar 11, 2026
Merged

feat: issue subgraph check extensions for proposals#2615
wilsonrivera merged 8 commits intomainfrom
wilson/eng-9071-investigation-missing-check-extensions-on-proposal

Conversation

@wilsonrivera
Copy link
Copy Markdown
Contributor

@wilsonrivera wilsonrivera commented Mar 9, 2026

Summary by CodeRabbit

  • New Features

    • Multi-subgraph schema checks: per-subgraph linting and pruning issues are sent, surfaced, and persisted; extension delivery IDs and error messages are recorded.
  • Bug Fixes

    • Improved webhook delivery/error tracking and reporting.
    • Fixed blob storage key and CDN URL formatting.
  • Tests

    • End-to-end tests added for multi-subgraph webhook flows and payload validation.

Checklist

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 9, 2026

Walkthrough

Schema check extension flow changed from single-subgraph to multi-subgraph: repositories now track per-subgraph lintIssues and pruneIssues in-memory and persist them; webhook payloads/return shapes and OrganizationWebhookService API were updated to send/receive arrays of subgraphs with per-subgraph fields; tests added for the new flow.

Changes

Cohort / File(s) Summary
Repository per-subgraph tracking
controlplane/src/core/repositories/SchemaCheckRepository.ts, controlplane/src/core/repositories/SubgraphRepository.ts
Introduce a local ExtendedCheckSubgraph type and change in-memory maps to Map<string, ExtendedCheckSubgraph>; initialize lintIssues/pruneIssues per subgraph; include those fields in webhook payloads; apply and persist per-subgraph lint issues from webhook results; adjust update payload to record deliveryId/errorMessage.
Webhook service multi-subgraph refactor
controlplane/src/core/webhooks/OrganizationWebhookService.ts
Change API from single subgraph to subgraphs[]; payload items now include lintIssues, pruneIssues, optional composed SDL and schemaChanges; adjust blob key/CDN URL construction and request content-type; parse and return lintIssuesBySubgraph (Map); remove public export of SubgraphDTO.
Tests: subgraph check extensions
controlplane/test/subgraph-check-extensions.test.ts
Add test scaffolding and helpers to create a federated graph with two subgraphs, mock axios for webhook posts, upload/read blob payloads, and assert webhook invocation and persisted extension error/lint handling. Note: a test block is duplicated in the diff.
Misc / manifest
manifest_file, package.json
Minor manifest/package changes (metadata/dependency alignment) accompanying the refactor.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: issue subgraph check extensions for proposals' accurately summarizes the main change: enabling subgraph check extensions to be issued for proposals. The PR modifies SchemaCheckRepository, SubgraphRepository, and OrganizationWebhookService to support per-subgraph lint/prune issues in webhook payloads, directly aligning with the stated feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
controlplane/src/core/webhooks/OrganizationWebhookService.ts (1)

754-761: Silent error suppression may hide webhook response parsing issues.

The try-catch block silently swallows any error when converting the lintIssues record to a Map. If the webhook returns malformed data that passes Zod validation but fails during Map conversion, this could silently drop lint issues without any logging or indication to the caller.

💡 Consider logging the error for debugging
         if (typeof parsedResponse.data.lintIssues === 'object') {
           try {
             const lintIssuesRecord = parsedResponse.data.lintIssues as Record<string, LintIssueResult[]>;
             lintIssuesBySubgraph = new Map(Object.entries(lintIssuesRecord));
           } catch {
-            // ignore
+            this.logger.debug('Failed to parse lintIssues from check extension response');
           }
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@controlplane/src/core/webhooks/OrganizationWebhookService.ts` around lines
754 - 761, The try-catch that converts parsedResponse.data.lintIssues to a Map
in OrganizationWebhookService (the block that creates lintIssuesRecord and sets
lintIssuesBySubgraph) currently swallows errors; modify the catch to log the
caught error and relevant context (e.g., the malformed
parsedResponse.data.lintIssues and identifying info like the webhook id or
response metadata) using the existing logger so failures converting to Map
aren't silent, while still preserving the fallback behavior; ensure the log
message references lintIssuesBySubgraph and LintIssueResult so it’s easy to
trace.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@controlplane/src/core/repositories/SchemaCheckRepository.ts`:
- Around line 1327-1341: Replace the hardcoded isDeleted: false in the subgraph
mapping with the actual deletion flag from the check/subgraph object; when
constructing subgraphs from checkSubgraphs (the destructure [subgraphName, {
subgraph, ...check }]), set isDeleted to the real value (e.g.,
subgraph?.isDeleted ?? check?.isDeleted ?? false) so deleted subgraphs that
produced an empty newSchemaSDL are reported correctly in the webhook payload.

---

Nitpick comments:
In `@controlplane/src/core/webhooks/OrganizationWebhookService.ts`:
- Around line 754-761: The try-catch that converts
parsedResponse.data.lintIssues to a Map in OrganizationWebhookService (the block
that creates lintIssuesRecord and sets lintIssuesBySubgraph) currently swallows
errors; modify the catch to log the caught error and relevant context (e.g., the
malformed parsedResponse.data.lintIssues and identifying info like the webhook
id or response metadata) using the existing logger so failures converting to Map
aren't silent, while still preserving the fallback behavior; ensure the log
message references lintIssuesBySubgraph and LintIssueResult so it’s easy to
trace.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 02d4d278-01da-49bb-be37-81b7fc1f38ed

📥 Commits

Reviewing files that changed from the base of the PR and between ea70e91 and ff1b962.

📒 Files selected for processing (4)
  • controlplane/src/core/repositories/SchemaCheckRepository.ts
  • controlplane/src/core/repositories/SubgraphRepository.ts
  • controlplane/src/core/webhooks/OrganizationWebhookService.ts
  • controlplane/test/subgraph-check-extensions.test.ts

Comment thread controlplane/src/core/repositories/SchemaCheckRepository.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 73.98374% with 32 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.58%. Comparing base (bea448f) to head (bdf6a03).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ane/src/core/repositories/SchemaCheckRepository.ts 68.51% 17 Missing ⚠️
...lplane/src/core/repositories/SubgraphRepository.ts 66.66% 8 Missing ⚠️
...ne/src/core/webhooks/OrganizationWebhookService.ts 84.44% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2615      +/-   ##
==========================================
+ Coverage   62.79%   64.58%   +1.78%     
==========================================
  Files         244      301      +57     
  Lines       25818    42876   +17058     
  Branches        0     4600    +4600     
==========================================
+ Hits        16213    27690   +11477     
- Misses       8223    15165    +6942     
+ Partials     1382       21    -1361     
Files with missing lines Coverage Δ
...ne/src/core/webhooks/OrganizationWebhookService.ts 58.27% <84.44%> (ø)
...lplane/src/core/repositories/SubgraphRepository.ts 88.12% <66.66%> (ø)
...ane/src/core/repositories/SchemaCheckRepository.ts 71.06% <68.51%> (ø)

... and 542 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wilsonrivera wilsonrivera marked this pull request as ready for review March 9, 2026 19:03
Comment thread controlplane/src/core/repositories/SubgraphRepository.ts
@wilsonrivera wilsonrivera requested a review from JivusAyrus March 10, 2026 16:49
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@controlplane/src/core/repositories/SchemaCheckRepository.ts`:
- Around line 1344-1348: The mapping that builds webhook payloads in
SchemaCheckRepository currently uses subgraph?.labels ?? [] which drops labels
for new proposal subgraphs where subgraph is undefined; update the mapping over
checkSubgraphs (the map that creates objects with id, name, labels, schemaSDL)
to use check.labels as the fallback (e.g., labels: subgraph?.labels ??
check.labels ?? []) so new subgraphs preserve their labels in the webhook
payload.
- Around line 1360-1385: The loop that processes sceResult.lintIssuesBySubgraph
only appends to per-subgraph check.lintIssues but doesn't add those issues into
the aggregate lintWarnings/lintErrors or flip hasLintErrors; update the loop
inside SchemaCheckRepository (the block iterating checkSubgraphs) to also push
sceLintIssues into the top-level lintWarnings and lintErrors arrays (filter by
LintSeverity.warn/error) and/or set a local flag so that when calling
this.update(...) the hasLintErrors value reflects any extension-reported
error-severity issues; keep the existing call to
schemaLintRepo.addSchemaCheckLintIssues(checkSubgraphId) intact.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4daf383-6b5f-42e5-a221-a5db5c6ca574

📥 Commits

Reviewing files that changed from the base of the PR and between d0952ad and 4a05f73.

📒 Files selected for processing (2)
  • controlplane/src/core/repositories/SchemaCheckRepository.ts
  • controlplane/src/core/repositories/SubgraphRepository.ts

Comment thread controlplane/src/core/repositories/SchemaCheckRepository.ts
Comment thread controlplane/src/core/repositories/SchemaCheckRepository.ts
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
controlplane/src/core/repositories/SchemaCheckRepository.ts (1)

1360-1381: Redundant filtering detected.

Lines 1364-1365 create sceLintWarnings and sceLintErrors by filtering sceLintIssues, but lines 1367-1368 re-filter the same array instead of using the already-filtered variables. Use the pre-filtered variables for consistency and efficiency.

♻️ Proposed fix
           const sceLintWarnings = sceLintIssues.filter((issue) => issue.severity === LintSeverity.warn);
           const sceLintErrors = sceLintIssues.filter((issue) => issue.severity === LintSeverity.error);

-          check.lintIssues.warnings.push(...sceLintIssues.filter((issue) => issue.severity === LintSeverity.warn));
-          check.lintIssues.errors.push(...sceLintIssues.filter((issue) => issue.severity === LintSeverity.error));
+          check.lintIssues.warnings.push(...sceLintWarnings);
+          check.lintIssues.errors.push(...sceLintErrors);

           lintWarnings.push(...sceLintWarnings.map((issue) => new LintIssue({ ...issue, subgraphName })));
           lintErrors.push(...sceLintErrors.map((issue) => new LintIssue({ ...issue, subgraphName })));
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@controlplane/src/core/repositories/SchemaCheckRepository.ts` around lines
1360 - 1381, In SchemaCheckRepository inside the loop over checkSubgraphs, avoid
re-filtering sceLintIssues — use the precomputed arrays sceLintWarnings and
sceLintErrors instead: replace the push calls that currently do
check.lintIssues.warnings.push(...sceLintIssues.filter(...)) and
check.lintIssues.errors.push(...sceLintIssues.filter(...)) to push the
already-filtered sceLintWarnings and sceLintErrors variables; keep the mappings
that create new LintIssue instances from sceLintWarnings/sceLintErrors and leave
schemaLintRepo.addSchemaCheckLintIssues as-is.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@controlplane/src/core/repositories/SchemaCheckRepository.ts`:
- Around line 1360-1381: In SchemaCheckRepository inside the loop over
checkSubgraphs, avoid re-filtering sceLintIssues — use the precomputed arrays
sceLintWarnings and sceLintErrors instead: replace the push calls that currently
do check.lintIssues.warnings.push(...sceLintIssues.filter(...)) and
check.lintIssues.errors.push(...sceLintIssues.filter(...)) to push the
already-filtered sceLintWarnings and sceLintErrors variables; keep the mappings
that create new LintIssue instances from sceLintWarnings/sceLintErrors and leave
schemaLintRepo.addSchemaCheckLintIssues as-is.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0105869d-5c6c-4958-b6ca-4b5c6965f627

📥 Commits

Reviewing files that changed from the base of the PR and between 4a05f73 and 0c578b9.

📒 Files selected for processing (1)
  • controlplane/src/core/repositories/SchemaCheckRepository.ts

@wilsonrivera wilsonrivera merged commit 0ea3e7d into main Mar 11, 2026
11 checks passed
@wilsonrivera wilsonrivera deleted the wilson/eng-9071-investigation-missing-check-extensions-on-proposal branch March 11, 2026 17:34
@coderabbitai coderabbitai Bot mentioned this pull request Mar 30, 2026
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants