@@ -53,13 +53,19 @@ const SCHEMAS: Record<string, unknown> = {
5353 beta : lookup ( 'beta' , 'dp_beta' ) ,
5454 open : lookup ( 'open' , 'dp_open' ) ,
5555 hidden : lookup ( 'hidden' , 'dp_hidden' ) ,
56+ off : lookup ( 'off' , 'dp_off' ) ,
57+ listed : lookup ( 'listed' , 'dp_listed' ) ,
5658 } ) ,
5759 // The object the disable takes offline.
5860 dp_beta : object ( 'dp_beta' , undefined , { secret_note : { name : 'secret_note' , label : 'Note' , type : 'text' } } ) ,
5961 // Enabled and exposed, with a lookup into the disabled one a hop further on.
6062 dp_open : object ( 'dp_open' , undefined , { inner : lookup ( 'inner' , 'dp_beta' ) } ) ,
6163 // CONTROL: switched off by its own exposure, not by a package disable.
6264 dp_hidden : object ( 'dp_hidden' , { apiEnabled : false } ) ,
65+ // [#35528] Disabled AND unexposed: the off switch, and a whitelist that
66+ // serves `get` (so `$expand`) but not `list` (so a relation condition).
67+ dp_off : object ( 'dp_off' , { apiEnabled : false } ) ,
68+ dp_listed : object ( 'dp_listed' , { apiMethods : [ 'get' ] } ) ,
6369} ;
6470
6571function makeProtocol ( opts : { disabled : Set < string > ; registryAnswers ?: boolean } ) {
@@ -161,3 +167,30 @@ describe('[#35427] a nested-relation condition on a disabled package\'s object i
161167 expect ( find ) . toHaveBeenCalledTimes ( 1 ) ;
162168 } ) ;
163169} ) ;
170+
171+ describe ( '[#35528] a target both package-disabled and unexposed answers the package refusal first' , ( ) => {
172+ const BOTH = new Set ( [ 'dp_off' , 'dp_listed' ] ) ;
173+ const conditionError = async ( disabled : Set < string > , rel : string ) : Promise < any > => {
174+ const { p, find } = makeProtocol ( { disabled } ) ;
175+ const err : any = await p . findData ( { object : 'dp_source' , query : { where : { [ rel ] : { name : 'x' } } } , context : SYSTEM } as any ) . catch ( ( e ) => e ) ;
176+ expect ( find ) . not . toHaveBeenCalled ( ) ;
177+ return { code : err . code , status : err . status , object : err . object } ;
178+ } ;
179+
180+ it ( 'THE PIN: the relation condition answers 404 OBJECT_PACKAGE_DISABLED, not the exposure refusal' , async ( ) => {
181+ expect ( await conditionError ( BOTH , 'off' ) ) . toEqual ( { code : 'OBJECT_PACKAGE_DISABLED' , status : 404 , object : 'dp_off' } ) ;
182+ expect ( await conditionError ( BOTH , 'listed' ) ) . toEqual ( { code : 'OBJECT_PACKAGE_DISABLED' , status : 404 , object : 'dp_listed' } ) ;
183+ } ) ;
184+
185+ it ( 'THE PIN: $expand withholds both entries' , async ( ) => {
186+ expect ( await expandHandedToFind ( BOTH , { expand : { off : { object : 'off' } , listed : { object : 'listed' } , open : { object : 'open' } } } ) )
187+ . toEqual ( { open : { object : 'open' } } ) ;
188+ } ) ;
189+
190+ it ( 'CONTROL: re-enabled, each answers its own exposure (off 404 / whitelist 405, the whitelist expanded)' , async ( ) => {
191+ expect ( await conditionError ( ENABLED , 'off' ) ) . toEqual ( { code : 'OBJECT_API_DISABLED' , status : 404 , object : 'dp_off' } ) ;
192+ expect ( await conditionError ( ENABLED , 'listed' ) ) . toEqual ( { code : 'OBJECT_API_METHOD_NOT_ALLOWED' , status : 405 , object : 'dp_listed' } ) ;
193+ expect ( await expandHandedToFind ( ENABLED , { expand : { off : { object : 'off' } , listed : { object : 'listed' } } } ) )
194+ . toEqual ( { listed : { object : 'listed' } } ) ;
195+ } ) ;
196+ } ) ;
0 commit comments