Retrieve the unencrypted record key from nested_share_records or record_cache.
(params, record_uid: str, raise_on_missing: bool = True)
| 78 | |
| 79 | |
| 80 | def get_record_key(params, record_uid: str, raise_on_missing: bool = True) -> Optional[bytes]: |
| 81 | """Retrieve the unencrypted record key from nested_share_records or record_cache.""" |
| 82 | for cache in (getattr(params, 'nested_share_records', {}), |
| 83 | getattr(params, 'record_cache', {})): |
| 84 | obj = cache.get(record_uid) |
| 85 | if obj and 'record_key_unencrypted' in obj: |
| 86 | return obj['record_key_unencrypted'] |
| 87 | if raise_on_missing: |
| 88 | raise ValueError( |
| 89 | f"Record key not found for record {record_uid}. " |
| 90 | f"Record may not exist or is not accessible.") |
| 91 | return None |
| 92 | |
| 93 | |
| 94 | def get_record_from_cache(params, record_uid: str) -> Optional[dict]: |
no test coverage detected