Retrieve the unencrypted record key from nested_share_records or record_cache.
(params, record_uid: str, raise_on_missing: bool = True)
| 34 | |
| 35 | |
| 36 | def get_record_key(params, record_uid: str, raise_on_missing: bool = True) -> Optional[bytes]: |
| 37 | """Retrieve the unencrypted record key from nested_share_records or record_cache.""" |
| 38 | for cache in (getattr(params, 'nested_share_records', {}), |
| 39 | getattr(params, 'record_cache', {})): |
| 40 | obj = cache.get(record_uid) |
| 41 | if obj and 'record_key_unencrypted' in obj: |
| 42 | return obj['record_key_unencrypted'] |
| 43 | if raise_on_missing: |
| 44 | raise ValueError( |
| 45 | f"Record key not found for record {record_uid}. " |
| 46 | f"Record may not exist or is not accessible.") |
| 47 | return None |
| 48 | |
| 49 | |
| 50 | def get_record_from_cache(params, record_uid: str) -> Optional[dict]: |
no test coverage detected