File tree Expand file tree Collapse file tree
apps/sim/lib/sim-search/live Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -441,6 +441,27 @@ describe('authorized live retrieval', () => {
441441 ) . rejects . toBe ( reason )
442442 }
443443 )
444+ it ( 'rejects a read cancelled while its current scope was being verified' , async ( ) => {
445+ const search = await searchLiveKnowledge . execute ( { principal, input } )
446+ const controller = new AbortController ( )
447+ mocks . service . mockResolvedValueOnce ( undefined )
448+ mocks . service . mockImplementationOnce ( async ( ) => {
449+ controller . abort ( 'user_stop:test' )
450+ return { policy : defaultLiveSearchPolicy ( ) , verify : async ( ) => true , partial : false }
451+ } )
452+ await expect (
453+ readLiveDocument . execute ( {
454+ principal,
455+ input : {
456+ workspaceId : 'workspace' ,
457+ documentId : search . results [ 0 ] ! . documentId ,
458+ limit : 1 ,
459+ resultSecretRegistry : new ResolvedSecretTraceRegistry ( [ ] ) ,
460+ signal : controller . signal ,
461+ } ,
462+ } )
463+ ) . rejects . toBe ( 'user_stop:test' )
464+ } )
444465 it ( 'rejects cross-user document references before token resolution' , async ( ) => {
445466 const search = await searchLiveKnowledge . execute ( { principal, input } )
446467 const reference = decodeLiveReference ( search . results [ 0 ] . documentId )
Original file line number Diff line number Diff line change @@ -663,7 +663,10 @@ export const readLiveDocument = defineAuthorizedKnowledgeUseCase({
663663 document = await measureSearchStage ( 'live.read' , ( ) => session . read ( reference , input . filters ) )
664664 /** Readers degrade section failures to warnings, so the signal decides cancellation. */
665665 signal . throwIfAborted ( )
666- if ( ! ( await session . verifyCurrent ( document ) ) )
666+ const current = await session . verifyCurrent ( document )
667+ /** A verifier may report a check cut short by cancellation as a normal result. */
668+ signal . throwIfAborted ( )
669+ if ( ! current )
667670 throw new OrchestrationError (
668671 'not_found' ,
669672 'Document is outside your organization’s search scope'
You can’t perform that action at this time.
0 commit comments