Repository navigation
fix: report prompt build failures with an id-free Sentry fingerprint #22952
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
61bf940
c2482c1
9689aea
aaceb9d
ef43424
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { beforeEach, describe, expect, it } from 'vitest' | ||
|
|
||
| import { | ||
| createTestSubgraph, | ||
| createTestSubgraphNode, | ||
| resetSubgraphFixtureState | ||
| } from '@/lib/litegraph/src/subgraph/__fixtures__/subgraphHelpers' | ||
| import { promptBuildErrorFingerprint } from '@/utils/promptBuildErrorFingerprint' | ||
|
|
||
| describe('promptBuildErrorFingerprint on real prompt build throwers', () => { | ||
| beforeEach(() => { | ||
| resetSubgraphFixtureState() | ||
| }) | ||
|
|
||
| function fingerprintOfThrow(run: () => void): string[] { | ||
| try { | ||
| run() | ||
| } catch (error) { | ||
| return promptBuildErrorFingerprint(error) | ||
| } | ||
| throw new Error('expected the prompt build thrower to throw') | ||
| } | ||
|
|
||
| it('groups SubgraphNode.rootGraph NullGraphError across string node ids', () => { | ||
| function detachedRootGraphAccess(nodeId: string) { | ||
| const subgraphNode = createTestSubgraphNode(createTestSubgraph(), { | ||
| id: nodeId | ||
| }) | ||
| subgraphNode.graph = null | ||
| return fingerprintOfThrow(() => subgraphNode.rootGraph) | ||
| } | ||
|
|
||
| expect(detachedRootGraphAccess('alpha')).toEqual([ | ||
| 'error_building_prompt', | ||
| 'NullGraphError', | ||
| 'SubgraphNode N has no graph' | ||
| ]) | ||
| expect(detachedRootGraphAccess('beta')).toEqual( | ||
| detachedRootGraphAccess('alpha') | ||
| ) | ||
| }) | ||
|
|
||
| it('groups SubgraphNode.getInnerNodes RecursionError across ids, titles and subgraph names', () => { | ||
| function selfVisitingInnerNodes( | ||
| nodeId: string, | ||
| title: string, | ||
| subgraphName: string | ||
| ) { | ||
| const subgraphNode = createTestSubgraphNode( | ||
| createTestSubgraph({ name: subgraphName }), | ||
| { id: nodeId } | ||
| ) | ||
| subgraphNode.title = title | ||
| return fingerprintOfThrow(() => | ||
| subgraphNode.getInnerNodes(new Map(), [], [], new Set([subgraphNode])) | ||
| ) | ||
| } | ||
|
|
||
| expect(selfVisitingInnerNodes('alpha', 'Load. Image', 'Detailer')).toEqual([ | ||
| 'error_building_prompt', | ||
| 'RecursionError', | ||
| 'Circular reference detected at depth N in node N of subgraph N' | ||
| ]) | ||
| expect(selfVisitingInnerNodes('beta', 'Upscale', 'Refiner')).toEqual( | ||
| selfVisitingInnerNodes('alpha', 'Load. Image', 'Detailer') | ||
| ) | ||
| expect( | ||
| selfVisitingInnerNodes('gamma', 'Load of node Image', 'Enhancer') | ||
| ).toEqual(selfVisitingInnerNodes('alpha', 'Load. Image', 'Detailer')) | ||
| }) | ||
| }) |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,137 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| import { describe, expect, it } from 'vitest' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| import { promptBuildErrorFingerprint } from '@/utils/promptBuildErrorFingerprint' | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| describe('promptBuildErrorFingerprint', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| it('groups missing output nodes across ids, slots and output names', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const first = new Error('No output node found for id [632] slot [0] images') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const second = new Error('No output node found for id [12:7] slot [3] mask') | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+7
to
+8
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Obtain DTO errors from their actual producers I changed only the real missing-output producer's wording from Replace the DTO-specific synthetic inputs with captured exceptions from real This fix spans the unit and producers files, so a local suggestion cannot safely replace the required fixtures and delete their synthetic copies. |
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(first)).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(second) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('keeps different failure kinds apart', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const missingOutput = new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'No output node found for id [1] slot [0] x' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const missingInput = new TypeError( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'No input found for flattened id [1] slot [0]' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(missingOutput)).not.toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(missingInput) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+15
to
+25
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Protect separation of same-class failure kinds I mutated the result to replace Rewrite this separation assertion to compare real input- and output-recursion errors with the same The replacement needs the DTO fixtures in the producers suite and removal or rewriting of this assertion, so the fix spans files rather than fitting this local range. |
||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it.for([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| thrower: 'ExecutableNodeDTO.resolveInput', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| suffix: ' during input resolution' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { thrower: 'SubgraphNode.rootGraph', suffix: '' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+32
to
+33
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Nit: delete the duplicate synthetic rootGraph row The real
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| ])( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'groups NullGraphError across numeric and string subgraph node ids ($thrower)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ({ suffix }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| function nullGraphError(nodeId: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const error = new Error(`SubgraphNode ${nodeId} has no graph${suffix}`) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error.name = 'NullGraphError' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return error | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(nullGraphError('alpha'))).toEqual([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'error_building_prompt', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'NullGraphError', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `SubgraphNode N has no graph${suffix}` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(nullGraphError('beta'))).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(nullGraphError('alpha')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(nullGraphError('42'))).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(nullGraphError('alpha')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('keeps the two NullGraphError sites apart', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const duringInput = new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'SubgraphNode alpha has no graph during input resolution' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const rootGraph = new Error('SubgraphNode alpha has no graph') | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint(duringInput)).not.toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(rootGraph) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('groups subgraph hierarchy recursion errors across ids, titles, names and depths', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| function hierarchyRecursionError( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| depth: number, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| nodeInfo: string, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| subgraphName: string | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const error = new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `Circular reference detected at depth ${depth} in node ${nodeInfo} of subgraph '${subgraphName}'. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `This creates an infinite loop in the subgraph hierarchy.` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error.name = 'RecursionError' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return error | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hierarchyRecursionError(2, 'alpha (Load. Image)', 'Detailer') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| hierarchyRecursionError(3, 'beta', 'Unnamed Subgraph') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+68
to
+91
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P3] Nit: delete the duplicate synthetic hierarchy case I would keep the real
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it.for([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { direction: 'input', path: '' }, | ||||||||||||||||||||||||||||||||||||||||||||||||||
| { direction: 'output', path: ' at path sub-a:sub-b' } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ])( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'groups recursion errors across string node ids, titles and paths ($direction)', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ({ direction, path }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| function recursionError(nodeInfo: string, uniqueId: string) { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| const error = new Error( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `Circular reference detected while resolving ${direction} 0 of node ${nodeInfo}${path}. ` + | ||||||||||||||||||||||||||||||||||||||||||||||||||
| `This creates an infinite loop in link resolution. UniqueID: [${uniqueId}]` | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| error.name = 'RecursionError' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| return error | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| recursionError('alpha (Load. Image)', 'x:alpha[I]0') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint(recursionError('beta', 'y:beta[I]0')) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('groups errors that end with a string node id', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| new TypeError('Node is not a subgraph node: alpha') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ).toEqual( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| promptBuildErrorFingerprint( | ||||||||||||||||||||||||||||||||||||||||||||||||||
| new TypeError('Node is not a subgraph node: beta') | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||
| it('uses the error name for values that are not errors', () => { | ||||||||||||||||||||||||||||||||||||||||||||||||||
| expect(promptBuildErrorFingerprint('boom 12')).toEqual([ | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'error_building_prompt', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Error', | ||||||||||||||||||||||||||||||||||||||||||||||||||
| 'boom N' | ||||||||||||||||||||||||||||||||||||||||||||||||||
| ]) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| }) | ||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,27 @@ | ||||||||||||||
| import { toError } from '@comfyorg/shared-frontend-utils/errorUtil' | ||||||||||||||
|
|
||||||||||||||
| const IDENTITY_POSITIONS: readonly (readonly [RegExp, string])[] = [ | ||||||||||||||
| [ | ||||||||||||||
| /^(Circular reference detected while resolving (?:input|output) \d+ of node) [\s\S]*$/, | ||||||||||||||
| '$1 N' | ||||||||||||||
| ], | ||||||||||||||
| [/ in node [\s\S]*? of subgraph [\s\S]*$/, ' in node N of subgraph N'], | ||||||||||||||
|
christian-byrne marked this conversation as resolved.
Resolved
|
||||||||||||||
| [/\b(Subgraph)?Node \S+ has no graph/, '$1Node N has no graph'], | ||||||||||||||
| [ | ||||||||||||||
| /^(No output node found for id \[[^\]]*\] slot \[[^\]]*\])\s+[\s\S]+$/, | ||||||||||||||
| '$1' | ||||||||||||||
| ], | ||||||||||||||
| [/\[[^\]]*\]/g, '[]'], | ||||||||||||||
|
christian-byrne marked this conversation as resolved.
Resolved
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P2] Normalize all four input-name suffixes I confirm the existing input-name finding and found one more affected format: The suggestion covers all four prefixes without merging their failure kinds. Add one table in the existing producers suite that obtains these failures from
Suggested change
|
||||||||||||||
| [/: \S+$/, ': N'], | ||||||||||||||
| [/\d+/g, 'N'] | ||||||||||||||
| ] | ||||||||||||||
|
|
||||||||||||||
| /** Sentry fingerprint for a prompt build failure, with node ids, titles, subgraph names, paths and slot indexes removed. */ | ||||||||||||||
| export function promptBuildErrorFingerprint(error: unknown): string[] { | ||||||||||||||
| const { name, message } = toError(error) | ||||||||||||||
| const shape = IDENTITY_POSITIONS.reduce( | ||||||||||||||
| (text, [position, placeholder]) => text.replace(position, placeholder), | ||||||||||||||
| message | ||||||||||||||
| ) | ||||||||||||||
| return ['error_building_prompt', name, shape] | ||||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [P1] Redact fingerprint components before sending them I reproduced a new path around the existing telemetry privacy filter. A widget serializer can reject with The same error message is therefore safe in I am not providing a one-hunk suggestion because the preferred fix spans this new caller and the central |
||||||||||||||
| } | ||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[P3] Check that the original rejection is preserved
I replaced this catch's
throw errorwith a fresh Error carrying the same message, and this test still passed.toThrow(failure)compares Error contents, not identity, so it misses loss of the original stack, cause or subclass. The PR explicitly promises to rethrow the original exception; check that object directly.