@@ -5746,9 +5746,19 @@ async function routeRequest(req, res) {
57465746 if ( req . method === "GET" && requestUrl . pathname === "/api/v1/agent-mail/leases" ) {
57475747 const includeReleased =
57485748 requestUrl . searchParams . get ( "include_released" ) === "true" ;
5749+ // Production trims the holder filter and ignores a blank value; the mock
5750+ // must enforce the same identity boundary rather than returning one
5751+ // convenient dataset for every acting principal.
5752+ const holderParam = requestUrl . searchParams . get ( "holder_principal" ) ;
5753+ const holder =
5754+ typeof holderParam === "string" && holderParam . trim ( )
5755+ ? holderParam . trim ( )
5756+ : null ;
57495757 sendJson ( res , 200 , {
5750- items : agentMailLeases . filter ( ( lease ) =>
5751- includeReleased ? true : lease . released_at === null ,
5758+ items : agentMailLeases . filter (
5759+ ( lease ) =>
5760+ ( includeReleased ? true : lease . released_at === null ) &&
5761+ ( holder === null || lease . holder_principal === holder ) ,
57525762 ) ,
57535763 } ) ;
57545764 return ;
@@ -5771,7 +5781,7 @@ async function routeRequest(req, res) {
57715781 lease_id : `mail-lease-${ nextAgentMailCounter ++ } ` ,
57725782 holder_principal :
57735783 typeof payload . holder_principal === "string" && payload . holder_principal . trim ( )
5774- ? payload . holder_principal
5784+ ? payload . holder_principal . trim ( )
57755785 : "agent-root" ,
57765786 glob_pattern : globPattern ,
57775787 exclusive : Boolean ( payload . exclusive ) ,
0 commit comments