-
-
Notifications
You must be signed in to change notification settings - Fork 24.5k
fix: add null checks in document store component node functions #6406
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 1 commit
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 | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1583,6 +1583,9 @@ const _createEmbeddingsObject = async ( | |||||||||||||||||||||||||
| ): Promise<any> => { | ||||||||||||||||||||||||||
| // prepare embedding node data | ||||||||||||||||||||||||||
| const embeddingComponent = componentNodes[data.embeddingName] | ||||||||||||||||||||||||||
| if (!embeddingComponent) { | ||||||||||||||||||||||||||
| throw new InternalFlowiseError(StatusCodes.INTERNAL_SERVER_ERROR, `Embedding "${data.embeddingName}" not found in component nodes`) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
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. To ensure consistency with the check implemented in _createVectorStoreObject and to prevent a potential crash during the dynamic import at line 1607, this check should also verify that embeddingComponent.filePath is defined. This promotes fail-fast behavior by throwing an error for invalid configurations. if (!embeddingComponent || !embeddingComponent.filePath) {
throw new InternalFlowiseError(
StatusCodes.INTERNAL_SERVER_ERROR,
"Embedding " + data.embeddingName + " not found or filePath not configured in component nodes"
)
}References
|
||||||||||||||||||||||||||
| const embeddingNodeData: any = { | ||||||||||||||||||||||||||
| inputs: { ...data.embeddingConfig }, | ||||||||||||||||||||||||||
| outputs: { output: 'document' }, | ||||||||||||||||||||||||||
|
|
@@ -1618,6 +1621,12 @@ const _createRecordManagerObject = async ( | |||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||
| // prepare record manager node data | ||||||||||||||||||||||||||
| const recordManagerComponent = componentNodes[data.recordManagerName] | ||||||||||||||||||||||||||
| if (!recordManagerComponent) { | ||||||||||||||||||||||||||
| throw new InternalFlowiseError( | ||||||||||||||||||||||||||
| StatusCodes.INTERNAL_SERVER_ERROR, | ||||||||||||||||||||||||||
| `Record Manager "${data.recordManagerName}" not found in component nodes` | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
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. Similar to the embeddings check, verifying the existence of filePath here is important because it is used for the dynamic import at line 1647. Adding this check maintains consistency across the component creation functions and ensures that missing configurations are handled explicitly by throwing an error.
Suggested change
References
|
||||||||||||||||||||||||||
| const rmNodeData: any = { | ||||||||||||||||||||||||||
| inputs: { ...data.recordManagerConfig }, | ||||||||||||||||||||||||||
| id: `${recordManagerComponent.name}_0`, | ||||||||||||||||||||||||||
|
|
@@ -1646,6 +1655,12 @@ const _createRecordManagerObject = async ( | |||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| const _createVectorStoreNodeData = (componentNodes: IComponentNodes, data: ICommonObject, embeddingObj: any, recordManagerObj?: any) => { | ||||||||||||||||||||||||||
| const vectorStoreComponent = componentNodes[data.vectorStoreName] | ||||||||||||||||||||||||||
| if (!vectorStoreComponent) { | ||||||||||||||||||||||||||
| throw new InternalFlowiseError( | ||||||||||||||||||||||||||
| StatusCodes.INTERNAL_SERVER_ERROR, | ||||||||||||||||||||||||||
| `Vector Store "${data.vectorStoreName}" not found in component nodes` | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| const vStoreNodeData: any = { | ||||||||||||||||||||||||||
| id: `${vectorStoreComponent.name}_0`, | ||||||||||||||||||||||||||
| inputs: { ...data.vectorStoreConfig }, | ||||||||||||||||||||||||||
|
|
@@ -1679,7 +1694,14 @@ const _createVectorStoreObject = async ( | |||||||||||||||||||||||||
| vStoreNodeData: INodeData, | ||||||||||||||||||||||||||
| upsertHistory?: Record<string, any> | ||||||||||||||||||||||||||
| ) => { | ||||||||||||||||||||||||||
| const vStoreNodeInstanceFilePath = componentNodes[data.vectorStoreName].filePath as string | ||||||||||||||||||||||||||
| const vectorStoreComponent = componentNodes[data.vectorStoreName] | ||||||||||||||||||||||||||
| if (!vectorStoreComponent || !vectorStoreComponent.filePath) { | ||||||||||||||||||||||||||
| throw new InternalFlowiseError( | ||||||||||||||||||||||||||
| StatusCodes.INTERNAL_SERVER_ERROR, | ||||||||||||||||||||||||||
| `Vector Store "${data.vectorStoreName}" not found or filePath not configured in component nodes` | ||||||||||||||||||||||||||
| ) | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| const vStoreNodeInstanceFilePath = vectorStoreComponent.filePath as string | ||||||||||||||||||||||||||
| const vStoreNodeModule = await import(vStoreNodeInstanceFilePath) | ||||||||||||||||||||||||||
| const vStoreNodeInstance = new vStoreNodeModule.nodeClass() | ||||||||||||||||||||||||||
| if (upsertHistory) upsertHistory['flowData'] = saveUpsertFlowData(vStoreNodeData, upsertHistory) | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
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.
The addition of a large number of packages to onlyBuiltDependencies is a significant change that bypasses the pnpm security sandbox for post-install scripts. This change is unrelated to the PRs objective of adding null checks and should be justified or moved to a separate PR. Furthermore, packages like core-js, core-js-pure, and es5-ext are pure JavaScript libraries that typically do not require native compilation and should not be in this list.