Retrieve the unencrypted record key from nested_share_records or record_cache.
(params, record_uid: str, raise_on_missing: bool = True)
| 43 | |
| 44 | |
| 45 | def get_record_key(params, record_uid: str, raise_on_missing: bool = True) -> Optional[bytes]: |
| 46 | """Retrieve the unencrypted record key from nested_share_records or record_cache.""" |
| 47 | for cache in (getattr(params, 'nested_share_records', {}), |
| 48 | getattr(params, 'record_cache', {})): |
| 49 | obj = cache.get(record_uid) |
| 50 | if obj and 'record_key_unencrypted' in obj: |
| 51 | return obj['record_key_unencrypted'] |
| 52 | if raise_on_missing: |
| 53 | raise ValueError( |
| 54 | f"Record key not found for record {record_uid}. " |
| 55 | f"Record may not exist or is not accessible.") |
| 56 | return None |
| 57 | |
| 58 | |
| 59 | def get_record_from_cache(params, record_uid: str) -> Optional[dict]: |
no test coverage detected