feat(upload): add ephemeral key prefix to POST /v1/upload#36
Open
thomashebrard wants to merge 1 commit into
Open
feat(upload): add ephemeral key prefix to POST /v1/upload#36thomashebrard wants to merge 1 commit into
thomashebrard wants to merge 1 commit into
Conversation
Add an optional `ephemeral: bool = False` field to `UploadRequest`. When
true, the stored object lands under `{user_id}/ephemeral/{uuid}.{ext}`
instead of `{user_id}/assets/…`. Everything else (auth gate, base64
decode, size cap, provider store, pipelex-storage:// return) is unchanged.
The key keeps `user_id` as its first segment so the storage-URL resolver
(`storage.py::parse_storage_uri`) still gates ownership on
`segments[0] == requester user_id` — ephemeral files remain resolvable by
their owner. The `/ephemeral/` segment separates synthetic, throwaway
sandbox inputs from durable user attachments under `/assets/`.
A 7-day auto-delete lifecycle for ephemeral objects is planned but
deferred: because the key is user_id-first, no single S3 prefix rule can
match `*/ephemeral/`, so the lifecycle must be tag-based — which needs
pipelex storage-provider tag-on-upload support (a release-gated core
change). This PR ships the prefix separation; the lifecycle lands later.
Additive optional field, `extra="forbid"` preserved — no breaking change.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="tests/unit/test_uploader.py">
<violation number="1" location="tests/unit/test_uploader.py:134">
P3: The test docstring implies the existing or planned S3 lifecycle rule filters on the `/ephemeral/` prefix, but the PR description explicitly says that's not possible — because the key is `user_id`-first, no single prefix rule can match `*/ephemeral/`, so the lifecycle must be tag-based and is deferred. Consider aligning the docstring with the actual plan (tag-based, deferred) to avoid misleading future readers.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| assert "/ephemeral/" not in key | ||
|
|
||
| def test_ephemeral_upload_lands_under_ephemeral_prefix(self, mocker: MockerFixture): | ||
| """`ephemeral=true` routes the object under '/ephemeral/', the exact key segment the |
There was a problem hiding this comment.
P3: The test docstring implies the existing or planned S3 lifecycle rule filters on the /ephemeral/ prefix, but the PR description explicitly says that's not possible — because the key is user_id-first, no single prefix rule can match */ephemeral/, so the lifecycle must be tag-based and is deferred. Consider aligning the docstring with the actual plan (tag-based, deferred) to avoid misleading future readers.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At tests/unit/test_uploader.py, line 134:
<comment>The test docstring implies the existing or planned S3 lifecycle rule filters on the `/ephemeral/` prefix, but the PR description explicitly says that's not possible — because the key is `user_id`-first, no single prefix rule can match `*/ephemeral/`, so the lifecycle must be tag-based and is deferred. Consider aligning the docstring with the actual plan (tag-based, deferred) to avoid misleading future readers.</comment>
<file context>
@@ -116,6 +116,35 @@ def test_storage_key_uses_authenticated_user_id(self, mocker: MockerFixture, fil
+ assert "/ephemeral/" not in key
+
+ def test_ephemeral_upload_lands_under_ephemeral_prefix(self, mocker: MockerFixture):
+ """`ephemeral=true` routes the object under '/ephemeral/', the exact key segment the
+ pipelex-api-infra S3 lifecycle rule filters on for 7-day auto-deletion.
+ """
</file context>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add an optional
ephemeral: bool = Falsefield toUploadRequest. When true, the stored object lands under{user_id}/ephemeral/{uuid}.{ext}instead of{user_id}/assets/…. Everything else (auth gate, base64 decode, size cap, provider store, pipelex-storage:// return) is unchanged.The key keeps
user_idas its first segment so the storage-URL resolver (storage.py::parse_storage_uri) still gates ownership onsegments[0] == requester user_id— ephemeral files remain resolvable by their owner. The/ephemeral/segment separates synthetic, throwaway sandbox inputs from durable user attachments under/assets/.A 7-day auto-delete lifecycle for ephemeral objects is planned but deferred: because the key is user_id-first, no single S3 prefix rule can match
*/ephemeral/, so the lifecycle must be tag-based — which needs pipelex storage-provider tag-on-upload support (a release-gated core change). This PR ships the prefix separation; the lifecycle lands later.Additive optional field,
extra="forbid"preserved — no breaking change.Summary by cubic
Add an optional
ephemeralflag to POST/v1/uploadto route files under{user_id}/ephemeral/...when true, keeping durable uploads under/assets/. Ownership checks and all other upload behavior are unchanged.UploadRequest.ephemeral(defaultfalse) to select storage prefix.{user_id}/{ephemeral|assets}/{uuid}.{ext};user_idstays first for ownership gating./assets/andephemeral=true/ephemeral/paths.Written for commit a0be00f. Summary will update on new commits.