fix(synapse): surface layer processing errors - #699
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughLayerProcessor now records the last processing error and exposes it via ChangesError Tracking in Synapse Pipeline Layers
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
📊 Coverage ReportCoverage report not available
Generated by PR Automation (Story 6.1) |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.aiox-core/core/synapse/engine.js:
- Around line 183-189: The getLayerError function currently calls
layer.getLastError() directly which can throw for malformed/custom layers;
update getLayerError to guard that call with a try/catch around invoking
layer.getLastError (checking typeof as now), return the caught error or a
wrapped Error with context if invocation fails, and otherwise return the
original result or null—ensure you only change getLayerError and keep its
signature so callers of getLayerError (and the process/_safeProcess flow)
receive a safe error object instead of letting exceptions propagate.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 0c9b4b10-27be-4b54-b57b-c21e07a35b40
📒 Files selected for processing (5)
.aiox-core/core/synapse/engine.js.aiox-core/core/synapse/layers/layer-processor.js.aiox-core/install-manifest.yamltests/synapse/engine.test.jstests/synapse/layer-processor.test.js
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/synapse/engine.test.js (1)
352-361: ⚡ Quick winAdd an explicit
layers_errored === 0assertion for the graceful-degradation path.The three new error-recording tests (lines 399–442) verify the "null + error" paths well. However, the complementary graceful-degradation path —
_safeProcessreturnsnullwhilegetLastError()returnsnullor is absent — has no assertion onlayers_errored. The existing "should return empty xml when no results" test (lines 352–361) covers this setup but only asserts onresult.xml; it won't catch a regression where null returns are incorrectly classified as errors in metrics.Given that this PR's core goal is accurate per-layer error telemetry, a false positive in
layers_erroredwould be a direct regression in the new feature.✅ Suggested assertion addition to the existing test
test('should return empty xml when no results', async () => { // Make all layers return null for (const layer of engine.layers) { layer._safeProcess = jest.fn(() => null); } formatter.formatSynapseRules.mockReturnValue(''); const result = await engine.process('test', {}); expect(result.xml).toBe(''); + // Graceful null returns (no getLastError / getLastError returns null) must NOT + // be classified as errors — they are silent skips, not telemetry-visible failures. + expect(result.metrics.layers_errored).toBe(0); });Also applies to: 399-442
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/synapse/engine.test.js` around lines 352 - 361, Add an explicit assertion that no layers were counted as errored when all layers return null: after calling engine.process in the "should return empty xml when no results" test, assert that result.metrics.layers_errored === 0 (or the equivalent metrics field on the returned result). Also add the same assertion to the complementary graceful-degradation tests that cover the "null + no getLastError()/null" paths so regressions that treat null returns as errors are caught; locate these tests by the use of layer._safeProcess mocks and formatter.formatSynapseRules expectations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tests/synapse/engine.test.js`:
- Around line 352-361: Add an explicit assertion that no layers were counted as
errored when all layers return null: after calling engine.process in the "should
return empty xml when no results" test, assert that
result.metrics.layers_errored === 0 (or the equivalent metrics field on the
returned result). Also add the same assertion to the complementary
graceful-degradation tests that cover the "null + no getLastError()/null" paths
so regressions that treat null returns as errors are caught; locate these tests
by the use of layer._safeProcess mocks and formatter.formatSynapseRules
expectations.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 1e2533aa-a058-4b57-81df-f0a71f5a447a
📒 Files selected for processing (3)
.aiox-core/core/synapse/engine.js.aiox-core/install-manifest.yamltests/synapse/engine.test.js
🚧 Files skipped from review as they are similar to previous changes (2)
- .aiox-core/core/synapse/engine.js
- .aiox-core/install-manifest.yaml
* fix(synapse): surface layer processing errors * fix(synapse): guard layer error accessors
Summary
SynapseEnginefrom classifying layer processing failures as plain skips when_safeProcess()swallowed the exception.LayerProcessor#getLastError()so graceful degradation still returnsnull, but the orchestrator can record the layer aserrorin metrics._safeProcess()exception boundary inSynapseEngineso malformed/custom layers do not crash the pipeline._safeProcess()throws in focused Synapse tests.Issue
Part of #621, specifically the concrete SynapseEngine silent-layer-failure telemetry slice.
Validation
node -c .aiox-core/core/synapse/engine.jsnode -c .aiox-core/core/synapse/layers/layer-processor.jsnpm test -- tests/synapse/engine.test.js tests/synapse/layer-processor.test.js --runInBand— 59 passednpm run generate:manifestnpm run validate:manifestgit diff --checknpm run lint— pass, 0 errors / 114 baseline warningsnpm run typecheck— passnode scripts/validate-package-completeness.js— pass, 34/34node bin/utils/validate-publish.js— pass, 4199 files in packageNote: the IDS pre-push registry hook produced an unsafe local entity-registry collision for generic
engine; that generated artifact was not included in this PR.Summary by CodeRabbit
New Features
Tests