Conversation
…contract connector field
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
… (#0) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## issue/16059-a-runtime-behavior #18308 +/- ##
===================================================================
- Coverage 34.65% 20.85% -13.80%
===================================================================
Files 3400 3335 -65
Lines 139050 128239 -10811
Branches 37713 37924 +211
===================================================================
- Hits 48181 26740 -21441
- Misses 90869 101499 +10630
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
Adds catalog revision polling so ingestion catalogs refresh when backend manifests change.
Changes:
- Adds the
catalogsRevisionsGraphQL endpoint and backend support. - Adds frontend polling, visibility handling, and catalog refetching.
- Adds backend and frontend polling tests.
Critical findings: the polling request can produce an unhandled rejection, and one test asserts a console message the implementation never emits.
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Summary |
|---|---|
opencti-platform/opencti-graphql/tests/03-integration/10-modules/catalog/catalog-resolver-test.ts |
Tests the revisions query payload. |
opencti-platform/opencti-graphql/src/modules/catalog/catalog.graphql |
Defines the revision type and query. |
opencti-platform/opencti-graphql/src/modules/catalog/catalog-types.ts |
Adds backend revision typing. |
opencti-platform/opencti-graphql/src/modules/catalog/catalog-resolver.ts |
Resolves catalog revisions. |
opencti-platform/opencti-graphql/src/modules/catalog/catalog-repository.ts |
Loads lightweight revision data. |
opencti-platform/opencti-graphql/src/modules/catalog/catalog-domain.ts |
Maps revision responses. |
opencti-platform/opencti-graphql/src/generated/graphql.ts |
Updates generated backend GraphQL types. |
opencti-platform/opencti-front/src/schema/relay.schema.graphql |
Updates frontend schema definitions. |
opencti-platform/opencti-front/src/private/components/integrations/Integrations.tsx |
Exposes catalog refetching. |
opencti-platform/opencti-front/src/private/components/integrations/catalog/IngestionConnectorsCatalog.tsx |
Defines the revision query. |
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts |
Implements visibility-aware polling; request failures can become unhandled rejections. |
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.test.ts |
Tests polling behavior; includes an assertion for an un emitted console message. |
opencti-platform/opencti-front/src/private/components/integrations/catalog/catalog-constants.ts |
Defines the polling interval. |
opencti-platform/opencti-front/src/private/components/integrations/available/IntegrationsAvailable.tsx |
Enables polling on the catalog page. |
Suppressed comments (3)
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:105
- If the catalog page is mounted while the browser tab is already hidden,
checkCatalogRevisionsreturns here before scheduling a timer, butwasPausedRefis never set. When the tab becomes visible, the visibility handler therefore does nothing and polling never starts until the page is remounted.
void checkCatalogRevisions();
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:85
refetchCatalogsonly callsloadCatalogsand returnsvoid, so thisawaitcompletes before the catalog query has succeeded. Updating the baseline immediately means a failed full-catalog refresh consumes the revision and later polls will not retry it, leaving stale contracts until another manifest revision or a page reload; advance the baseline only after a successful refresh.
await onCatalogRevisionsChanged();
baselineRef.current = nextBaseline;
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:72
- This polling call uses the shared
fetchQuerywrapper without anetwork-onlypolicy. Relay's default fetch policy can satisfy repeated executions from the store, so after the first response this timer can keep comparing the same cached revisions and never detect a backend manifest update; expose/pass a network-only policy for this query.
const result = await fetchQuery<IngestionConnectorsCatalogRevisionsQuery>(
ingestionConnectorsCatalogRevisionsQuery,
{},
).toPromise();
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 13 out of 14 changed files in this pull request and generated 1 comment.
Suppressed comments (3)
Previously missed (3) — in code that hasn't changed since the last review.
opencti-platform/opencti-front/src/private/components/integrations/Integrations.tsx:94
refetchCatalogsis recreated on everyIntegrationsDataProviderrender, whileuseCatalogPollingusesonCatalogRevisionsChangedas an effect dependency. Any provider update consequently tears down and restarts the poller, immediately issuing another revisions request and resetting the 60-second cadence. Memoize this callback (or make the hook keep a stable callback ref) so unrelated provider updates do not trigger extra polling.
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:90- The callback used here is
refetchCatalogs, which only startsloadCatalogsand returnsvoid; awaiting it does not wait for the full catalog request to succeed. The baseline is therefore advanced immediately, so a failed catalog refresh is treated as handled and will not be retried while the manifest revision remains unchanged. Have the callback resolve only after the catalog refresh succeeds, or update the baseline from the successful catalog data instead.
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:110 - When the page is mounted while the document is already hidden, the initial check returns at line 64 without setting
wasPausedRef. The latervisibilitychangehandler therefore seeswasPausedRef.current === falseand never starts polling after the tab becomes visible. Initialize the paused state fromdocument.hidden(and only start the initial check when visible) so background-opened catalog pages resume correctly.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 14 out of 15 changed files in this pull request and generated 3 comments.
Suppressed comments (5)
Previously missed (3) — in code that hasn't changed since the last review.
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:77
- Cleanup only stops future timers; an in-flight
fetchQuerycan still resolve after the user leaves the Available tab. In that case this code will invokeonCatalogRevisionsChanged, and the provider will reload catalogs even though polling has been disabled by unmount. CheckisUnmountedRef.currentafter the await before processing the response.
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:91 refetchCatalogsonly callsloadCatalogs, which is a fire-and-forget query-loader action and is typed as() => void. The baseline is therefore advanced before the full catalog request completes; if that request fails, polling sees the new revision as already handled and never retries, leaving the old catalog displayed. Return or await a refresh completion signal before updating the baseline, or keep the old baseline until a successful catalog refresh is confirmed.
opencti-platform/opencti-front/src/private/components/integrations/catalog/hooks/useCatalogPolling.ts:107- If this hook mounts while
document.hiddenis already true, the initial check returns at line 64 before settingwasPausedRef. When the tab becomes visible, this condition is false, so no revision check or timer is started and the page will never detect later catalog changes. Treat an initial hidden mount as paused (or also trigger when the baseline is still unset).
opencti-platform/opencti-front/src/private/components/integrations/Integrations.tsx:94
refetchCatalogsreturns immediately after schedulingloadCatalogs; it does not report whether thestore-and-networkcatalog request succeeded. The polling hook awaits this callback and then recordsnextBaselineas handled, so a transient full-catalog refresh failure can leave stale contracts displayed while suppressing retries until another revision appears. Propagate a completion signal and advance the baseline only after the catalog refresh succeeds.
const refetchCatalogs = () => {
if (isConnectorReader) {
loadCatalogs({}, { fetchPolicy: 'store-and-network' });
}
};
opencti-platform/opencti-front/src/private/components/integrations/Integrations.tsx:94
refetchCatalogsis recreated on everyIntegrationsDataProviderrender, whileuseCatalogPollingincludes it in the effect dependencies and performs an immediate check whenever that effect starts. Any provider update therefore tears down the 60-second timer and issues an extra revision request, including after a catalog refresh, which can create duplicate network traffic. Memoize this handler so the polling effect is stable.
const refetchCatalogs = () => {
if (isConnectorReader) {
loadCatalogs({}, { fetchPolicy: 'store-and-network' });
}
};
| if (!baselineRef.current) { | ||
| baselineRef.current = nextBaseline; | ||
| return; |
There was a problem hiding this comment.
🟡 Changes recommended
The new backend integration test queries/asserts id instead of the schema field catalog_id, which will fail at runtime until corrected.
Get a fresh assessment by requesting another Copilot review.
Review details
Suppressed comments (1)
opencti-platform/opencti-graphql/tests/03-integration/10-modules/catalog/catalog-resolver-test.ts:224
- These assertions still expect
id, but thecatalogsRevisionspayload containscatalog_id(andrevisionis nullable in the schema).
expect(Object.keys(revisionEntry).sort()).toEqual(['id', 'revision']);
expect(revisionEntry.id).toEqual(expect.any(String));
expect(revisionEntry.revision).toEqual(expect.any(String));
}
- Files reviewed: 14/15 changed files
- Comments generated: 1
- Review effort level: Lite
849a9d6 to
deb317a
Compare
|
closed and replaced by this PR #18332 |
Proposed changes
Related issues
How to test this PR
Checklist
Further comments