@@ -321,9 +321,32 @@ impl RadicleIdentityResolver {
321321 /// at `v1/devices/{shard}/{sanitized_did}/attestation.json`.
322322 fn find_controller_for_device ( & self , device_did : & Did ) -> Option < Did > {
323323 let id_path = self . identity_repo_path . as_ref ( ) . unwrap_or ( & self . repo_path ) ;
324- let repo = Repository :: open ( id_path) . ok ( ) ?;
325- let att = self . read_device_attestation ( & repo, device_did) ?;
326- att. issuer . to_string ( ) . parse :: < Did > ( ) . ok ( )
324+ eprintln ! (
325+ "[auths-debug] find_controller_for_device: id_path={}" ,
326+ id_path. display( )
327+ ) ;
328+ let repo = match Repository :: open ( id_path) {
329+ Ok ( r) => r,
330+ Err ( e) => {
331+ eprintln ! ( "[auths-debug] Repository::open failed: {e}" ) ;
332+ return None ;
333+ }
334+ } ;
335+ eprintln ! ( "[auths-debug] Repository opened successfully" ) ;
336+ let att = match self . read_device_attestation ( & repo, device_did) {
337+ Some ( a) => a,
338+ None => {
339+ eprintln ! ( "[auths-debug] read_device_attestation returned None" ) ;
340+ return None ;
341+ }
342+ } ;
343+ eprintln ! ( "[auths-debug] attestation found, issuer={}" , att. issuer) ;
344+ let result = att. issuer . to_string ( ) . parse :: < Did > ( ) . ok ( ) ;
345+ eprintln ! (
346+ "[auths-debug] parsed issuer DID: {:?}" ,
347+ result. as_ref( ) . map( |d| d. to_string( ) )
348+ ) ;
349+ result
327350 }
328351
329352 /// Scans the packed registry for all devices with attestations.
@@ -388,28 +411,76 @@ impl RadicleIdentityResolver {
388411 repo : & Repository ,
389412 device_did : & Did ,
390413 ) -> Option < auths_verifier:: core:: Attestation > {
391- let registry_tree = self . registry_tree ( repo) ?;
414+ let registry_tree = match self . registry_tree ( repo) {
415+ Some ( t) => t,
416+ None => {
417+ eprintln ! ( "[auths-debug] registry_tree returned None" ) ;
418+ return None ;
419+ }
420+ } ;
392421 let sanitized = device_did. to_string ( ) . replace ( ':' , "_" ) ;
393- let key_part = sanitized. strip_prefix ( "did_key_" ) ?;
422+ let key_part = match sanitized. strip_prefix ( "did_key_" ) {
423+ Some ( k) => k,
424+ None => {
425+ eprintln ! ( "[auths-debug] strip_prefix(did_key_) failed for: {sanitized}" ) ;
426+ return None ;
427+ }
428+ } ;
394429 if key_part. len ( ) < 4 {
430+ eprintln ! ( "[auths-debug] key_part too short: {key_part}" ) ;
395431 return None ;
396432 }
397433 let s1 = & key_part[ ..2 ] ;
398434 let s2 = & key_part[ 2 ..4 ] ;
399435 let att_path = format ! ( "v1/devices/{s1}/{s2}/{sanitized}/attestation.json" ) ;
436+ eprintln ! ( "[auths-debug] looking up att_path: {att_path}" ) ;
400437
401- let entry = registry_tree
402- . get_path ( std:: path:: Path :: new ( & att_path) )
403- . ok ( ) ?;
404- let blob = repo. find_blob ( entry. id ( ) ) . ok ( ) ?;
405- serde_json:: from_slice ( blob. content ( ) ) . ok ( )
438+ let entry = match registry_tree. get_path ( std:: path:: Path :: new ( & att_path) ) {
439+ Ok ( e) => e,
440+ Err ( e) => {
441+ eprintln ! ( "[auths-debug] tree.get_path failed: {e}" ) ;
442+ return None ;
443+ }
444+ } ;
445+ let blob = match repo. find_blob ( entry. id ( ) ) {
446+ Ok ( b) => b,
447+ Err ( e) => {
448+ eprintln ! ( "[auths-debug] find_blob failed: {e}" ) ;
449+ return None ;
450+ }
451+ } ;
452+ match serde_json:: from_slice ( blob. content ( ) ) {
453+ Ok ( att) => Some ( att) ,
454+ Err ( e) => {
455+ eprintln ! ( "[auths-debug] serde_json::from_slice failed: {e}" ) ;
456+ None
457+ }
458+ }
406459 }
407460
408461 /// Returns the root tree at `refs/auths/registry`.
409462 fn registry_tree < ' r > ( & self , repo : & ' r Repository ) -> Option < git2:: Tree < ' r > > {
410- let reference = repo. find_reference ( REGISTRY_REF ) . ok ( ) ?;
411- let commit = reference. peel_to_commit ( ) . ok ( ) ?;
412- commit. tree ( ) . ok ( )
463+ let reference = match repo. find_reference ( REGISTRY_REF ) {
464+ Ok ( r) => r,
465+ Err ( e) => {
466+ eprintln ! ( "[auths-debug] find_reference({REGISTRY_REF}) failed: {e}" ) ;
467+ return None ;
468+ }
469+ } ;
470+ let commit = match reference. peel_to_commit ( ) {
471+ Ok ( c) => c,
472+ Err ( e) => {
473+ eprintln ! ( "[auths-debug] peel_to_commit failed: {e}" ) ;
474+ return None ;
475+ }
476+ } ;
477+ match commit. tree ( ) {
478+ Ok ( t) => Some ( t) ,
479+ Err ( e) => {
480+ eprintln ! ( "[auths-debug] commit.tree() failed: {e}" ) ;
481+ None
482+ }
483+ }
413484 }
414485
415486 /// Reads KEL events by walking the commit chain from the given commit.
0 commit comments