feat(api): resolve export identity by idempotency key on loopback - #465
feat(api): resolve export identity by idempotency key on loopback#465seonghobae wants to merge 4 commits into
Conversation
GAP-003A unique slice: AnalysisRunLiveService serves naruon-only
GET /v1/exports/by-idempotency/{idempotency_key} as a metric-free
export_id lookup. NaruonLiveService stays POST-only. ADR 0093.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Team Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| let prefix = format!("{consumer}\u{1f}"); | ||
| let mut matches: Vec<&StoredExport> = self | ||
| .authorized_exports | ||
| .iter() | ||
| .filter(|(replay_key, stored)| { | ||
| replay_key.starts_with(&prefix) | ||
| && stored.retrieval.idempotency_key == idempotency_key | ||
| }) | ||
| .map(|(_, stored)| stored) | ||
| .collect(); | ||
| if matches.len() != 1 { | ||
| return Err(ApiError::InvalidWirePayload); | ||
| } | ||
| let stored = matches.remove(0); |
| if matches!( | ||
| export_idempotency_lookup_path_key(path), | ||
| Ok(_) | Err(ApiError::LimitExceeded) | ||
| ) { | ||
| return self.lookup_export_by_idempotency(path, &headers, body); | ||
| } |
| if encoded.is_empty() || encoded.contains('/') { | ||
| return Err(ApiError::InvalidWirePayload); | ||
| } | ||
| let key = decode_path_segment(encoded)?; |
There was a problem hiding this comment.
| fn contains_forbidden_export_lookup_key(value: &serde_json::Value) -> bool { | ||
| match value { | ||
| serde_json::Value::Object(object) => object.iter().any(|(key, value)| { | ||
| FORBIDDEN_EXPORT_LOOKUP_KEYS.contains(&key.as_str()) | ||
| || contains_forbidden_export_lookup_key(value) | ||
| }), | ||
| serde_json::Value::Array(values) => values.iter().any(contains_forbidden_export_lookup_key), | ||
| _ => false, | ||
| } |
Folded into #466
This predecessor is closed as
superseded_by_fold, not discarded. #466's current head contains this PR as its direct ancestor and has been retargeted to this PR's former base, so the GET implementation, tests, review history, RED79cb5d6cdbf8f18c82bb990a63d9282a278293e1, and repairse40b4078762b37e05ca85fd066009bb30bd663c4/0fd64f72cb0978d5603a5bf78954bb8e8f35d45aremain preserved while the open WIP count is reduced.Canonical landing vehicle: #466 (
feat/api: consolidate export idempotency lookup GET and CLI).Do not reopen this one-operation predecessor unless the folded head demonstrably loses unique behavior or evidence.