File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed
Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -589,6 +589,35 @@ describe('Serializer', () => {
589589 } ) . toThrow ( 'Test Jina Block is missing required fields: API Key' )
590590 } )
591591
592+ it . concurrent ( 'should skip validation for disabled blocks' , ( ) => {
593+ const serializer = new Serializer ( )
594+
595+ // Create a disabled block with a missing user-only required field
596+ const disabledBlockWithMissingField : any = {
597+ id : 'test-block' ,
598+ type : 'jina' ,
599+ name : 'Disabled Jina Block' ,
600+ position : { x : 0 , y : 0 } ,
601+ subBlocks : {
602+ url : { value : 'https://example.com' } ,
603+ apiKey : { value : null } , // Missing user-only required field
604+ } ,
605+ outputs : { } ,
606+ enabled : false , // Block is disabled
607+ }
608+
609+ // Should NOT throw error because the block is disabled
610+ expect ( ( ) => {
611+ serializer . serializeWorkflow (
612+ { 'test-block' : disabledBlockWithMissingField } ,
613+ [ ] ,
614+ { } ,
615+ undefined ,
616+ true
617+ )
618+ } ) . not . toThrow ( )
619+ } )
620+
592621 it . concurrent ( 'should not throw error when all user-only required fields are present' , ( ) => {
593622 const serializer = new Serializer ( )
594623
Original file line number Diff line number Diff line change @@ -429,6 +429,11 @@ export class Serializer {
429429 blockConfig : any ,
430430 params : Record < string , any >
431431 ) {
432+ // Skip validation if the block is disabled
433+ if ( block . enabled === false ) {
434+ return
435+ }
436+
432437 // Skip validation if the block is used as a trigger
433438 if (
434439 block . triggerMode === true ||
You can’t perform that action at this time.
0 commit comments