Feature/bucket label 1354#2094
Conversation
# Conflicts: # src/services/providers/BaseProvider.ts # src/services/providers/HttpProvider.ts # src/services/providers/P2pProvider.ts
There was a problem hiding this comment.
Claude Code Review
This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.
Tip: disable this comment in your organization's Code Review settings.
|
| Filename | Overview |
|---|---|
| src/@types/File.ts | Adds optional label to create-request and bucket types, and new PersistentStorageUpdateBucketResponse with non-optional label: string |
| src/@types/Provider.ts | Adds PERSISTENT_STORAGE_UPDATE_BUCKET command constant, straightforward addition |
| src/services/providers/BaseProvider.ts | Adds updatePersistentStorageBucket public method and label field to create-bucket return type; delegates correctly to the impl |
| src/services/providers/HttpProvider.ts | Adds HTTP PATCH implementation for updatePersistentStorageBucket; auth params go into query string while label goes into request body, consistent with existing methods |
| src/services/providers/P2pProvider.ts | Removes private getPersistentStorageSignaturePayload helper (replaced by direct getSignedCommandParams calls, consistent with all other P2P storage methods) and adds updatePersistentStorageBucket |
| test/integration/Provider.test.ts | Adds integration test covering label creation and rename; depends on server echoing label in the create response, which is not guaranteed by the current type |
| .github/CODEOWNERS | Adds @dnsi0 as a code owner, no issues |
Sequence Diagram
sequenceDiagram
participant Client
participant BaseProvider
participant HttpProvider
participant P2pProvider
participant Node as Ocean Node
Client->>BaseProvider: updatePersistentStorageBucket(nodeUri, signer, bucketId, label)
BaseProvider->>BaseProvider: getImpl(nodeUri)
alt HTTP node
BaseProvider->>HttpProvider: updatePersistentStorageBucket(...)
HttpProvider->>HttpProvider: getSignedCommandParams() → authPayload
HttpProvider->>Node: "PATCH /persistentStorage/buckets/{bucketId}?{authPayload} body: { label }"
Node-->>HttpProvider: "{ bucketId, label }"
HttpProvider-->>BaseProvider: PersistentStorageUpdateBucketResponse
else P2P node
BaseProvider->>P2pProvider: updatePersistentStorageBucket(...)
P2pProvider->>P2pProvider: getSignedCommandParams() → authPayload
P2pProvider->>Node: "P2P: PERSISTENT_STORAGE_UPDATE_BUCKET payload: { ...authPayload, bucketId, label }"
Node-->>P2pProvider: "{ bucketId, label }"
P2pProvider-->>BaseProvider: PersistentStorageUpdateBucketResponse
end
BaseProvider-->>Client: PersistentStorageUpdateBucketResponse
Reviews (2): Last reviewed commit: "add new codeowner" | Re-trigger Greptile
|
/run-security-scan |
alexcos20
left a comment
There was a problem hiding this comment.
AI automated code review (Gemini 3).
Overall risk: low
Summary:
This PR successfully introduces support for setting and updating labels on persistent storage buckets, including updates to types, HTTP, and P2P providers. The code is well-structured and includes integration tests to verify the new functionality. However, there is an inconsistency in how authentication payloads are handled in the HTTP provider's update method compared to creation, which should be addressed to prevent potential API rejection and to keep sensitive signatures out of URL logs.
Comments:
• [WARNING][bug] In updatePersistentStorageBucket, authPayload is being appended to the URL query string. In createPersistentStorageBucket, it is spread into the request body. If the backend API expects the authentication parameters (such as signature and nonce) in the request body for PATCH endpoints, this will result in an authorization error. Additionally, putting signatures in URL parameters exposes them to server access logs.
Consider moving the authPayload into the request body for consistency and better security hygiene:
- const query = new URLSearchParams({
- ...authPayload
- })
- const response = await fetch(`${routeBase}?${query.toString()}`, {
+ const response = await fetch(routeBase, {
method: 'PATCH',
headers,
- body: JSON.stringify({ label }),
+ body: JSON.stringify({ ...authPayload, label }),
signal
})• [INFO][style] Good cleanup removing the redundant getPersistentStorageSignaturePayload wrapper and calling getSignedCommandParams directly. This reduces boilerplate.
• [INFO][style] Excellent inclusion of an integration test that verifies both the creation of the bucket with a label and the update/renaming flow. LGTM!
Not a bug, the node's PATCH route reads auth from req.query, only label comes from the body, so this matches the backend |
Fixes oceanprotocol/ocean-node#1354
Changes proposed in this PR: