[CRE-1299] - support white listed requests#113
Conversation
There was a problem hiding this comment.
Pull request overview
This PR exposes per-submission strategic metadata end-to-end so that “white listed requests” (likely keyed off strategic metadata) can be represented on the Submission object and surfaced through the Python bindings.
Changes:
- Added
strategic_metadata: Option<StrategicMetadataMap>to the core RustSubmissiontype and initialized it in constructors. - Updated submission DB reads (
get_submission,submission_status) to fetch strategic metadata viasubmissions_metadata(usingjson_group_object) and normalize empty metadata toNone. - Extended the
opsqueue_pythonSubmissionbinding to includestrategic_metadataand include it in__repr__.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| opsqueue/src/common/submission.rs | Adds strategic_metadata to Submission and populates it from DB queries via submissions_metadata aggregation. |
| libs/opsqueue_python/src/common.rs | Surfaces strategic_metadata in the Python Submission wrapper and updates its __repr__. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| fn normalize_strategic_metadata( | ||
| strategic_metadata: Option<sqlx::types::Json<StrategicMetadataMap>>, | ||
| ) -> Option<StrategicMetadataMap> { | ||
| strategic_metadata.and_then(|json| (!json.0.is_empty()).then_some(json.0)) | ||
| } |
b8151e3 to
f5bed41
Compare
f5bed41 to
5692b0c
Compare
ReinierMaas
left a comment
There was a problem hiding this comment.
LGTM! I have two optional extensions, one is removing the type level distinction that doesn't actually exist. I think that would make the whole API easier to use and understand!
There was a problem hiding this comment.
I would like to point out that for the other queries we also assert the query plan. This allows us to spot potentially very bad execution behaviour. Could you add that for these queries?
| .expect("insertion failed"); | ||
|
|
||
| let fetched_submission = get_submission(submission.id, &mut conn).await.unwrap(); | ||
| // When fetched from DB with no metadata rows, json_group_object returns '{}'. |
There was a problem hiding this comment.
Ah so there is no distinction between Option<StrategicMetadataMap> and StrategicMetadataMap on the reader side?
Reading a bit further indeed shows to me that we can also remove the Option from the type to make this clear, this is also the type contract on InsertSubmission. Only the outer function insert_submission_chunks accepts the Option<StrategicMetadataMap> but it is unwrap_or_default into an empty map there.
No description provided.