Skip to content

Enhanced intermediate result upload response#162

Merged
pbrassel merged 4 commits intomainfrom
enhance-intermediate-upload-response
Apr 16, 2026
Merged

Enhanced intermediate result upload response#162
pbrassel merged 4 commits intomainfrom
enhance-intermediate-upload-response

Conversation

@pbrassel
Copy link
Copy Markdown
Member

@pbrassel pbrassel commented Apr 16, 2026

Summary by CodeRabbit

  • New Features

    • Improved node identification used when submitting and retrieving intermediate/uploaded files so the correct remote node is included in retrieval URLs.
  • Tests

    • Updated fixtures and test cases to reuse created test realms/nodes and to validate the updated node identification and retrieval behavior in upload flows.

…UploadResponse`

Since a file that is encrypted by node A is only decryptable with its own public key, the query parameter `remote_node_id` of the URL with that the encrypted file can be retrieved is directly set to the encrypting nodes ID.
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 16, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5d573ea5-2beb-4209-baac-2187f4af1ee3

📥 Commits

Reviewing files that changed from the base of the PR and between 753462f and e0a7976.

📒 Files selected for processing (2)
  • project/dependencies.py
  • tests/conftest.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • project/dependencies.py
  • tests/conftest.py

📝 Walkthrough

Walkthrough

Introduces a cached get_node_id() dependency that requires hub auth flow client, queries core_client.find_nodes by configured client ID, validates exactly one match, and returns the node ID (or raises 500). Injects this dependency into intermediate and local upload endpoints; tests and fixtures updated to match URL/query changes.

Changes

Cohort / File(s) Summary
Node ID Dependency
project/dependencies.py
Added cached get_node_id(settings, core_client) which enforces AuthFlow.client, queries core_client.find_nodes by client_id, validates a single node, and returns its id; raises HTTPException(500) on violations.
Upload Endpoints
project/routers/intermediate.py, project/routers/local.py
Added node_id: Annotated[uuid.UUID, Depends(get_node_id)] to upload endpoints; intermediate endpoint includes remote_node_id in generated retrieval URL; local router forwards node_id into intermediate submission call.
Tests: Fixtures & Overrides
tests/conftest.py
Imported get_node_id; changed realm_id and this_node fixtures to scope="package"; added override_get_node_id() and temporarily overrides get_node_id in test client after creating the node.
Tests: URL Handling
tests/test_intermediate.py, tests/test_local.py, tests/test_local_tagged.py
Updated test GET requests to use full path including model.url.query (e.g., f"{model.url.path}?{model.url.query}") and removed explicit params={"remote_node_id": ...} usage; added explicit response status assertion in one test.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant FastAPI_Endpoint
    participant get_node_id
    participant CoreClient
    participant URL_Generator

    Client->>FastAPI_Endpoint: POST upload request
    FastAPI_Endpoint->>get_node_id: Resolve dependency
    get_node_id->>CoreClient: find_nodes(filter={client_id: configured_id})
    CoreClient-->>get_node_id: nodes list
    get_node_id-->>FastAPI_Endpoint: node.id (or raise HTTPException)
    FastAPI_Endpoint->>URL_Generator: Build retrieval URL
    URL_Generator->>URL_Generator: include_query_params(remote_node_id=node.id)
    URL_Generator-->>FastAPI_Endpoint: retrieval URL with remote_node_id
    FastAPI_Endpoint-->>Client: Response containing URL
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Possibly related PRs

Poem

🐰 I dug through settings, soft and sly,

Found the node id hidden nearby.
I hopped it to endpoints, tucked in the query,
Tests now follow the trail, clean and merry.
A little cached hop — then back to my rye.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Enhanced intermediate result upload response' is vague and does not clearly convey the specific technical changes made in this pull request. Use a more descriptive title that explains the actual implementation change, such as 'Add node_id dependency to intermediate upload endpoint' or 'Include node_id in intermediate result upload'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enhance-intermediate-upload-response

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
project/dependencies.py (1)

223-223: Replace raw string with AuthFlow.client enum for consistency.

Line 223 uses a raw string comparison while the rest of the module compares against the AuthFlow enum (e.g., AuthFlow.password and AuthFlow.client elsewhere). Align this check with the existing pattern.

Suggested fix
-    if settings.hub.auth.flow != "client":
+    if settings.hub.auth.flow != AuthFlow.client:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@project/dependencies.py` at line 223, The code uses a raw string comparison
at settings.hub.auth.flow != "client"; change it to use the AuthFlow enum for
consistency by comparing settings.hub.auth.flow != AuthFlow.client, ensuring
AuthFlow is imported or referenced the same way as other checks (see existing
comparisons to AuthFlow.password and AuthFlow.client) so the module consistently
uses the enum values.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@project/dependencies.py`:
- Around line 218-222: Remove the `@lru_cache` decorator from get_node_id because
it depends on per-request objects from get_core_client (so cache keys never
hit); update the function to accept settings and core_client as before but
without caching. Also replace the string literal "client" used in the auth flow
check with the AuthFlow.client enum value to ensure type-safety (refer to
AuthFlow and the get_node_id function and the get_core_client dependency to
locate the change).

---

Nitpick comments:
In `@project/dependencies.py`:
- Line 223: The code uses a raw string comparison at settings.hub.auth.flow !=
"client"; change it to use the AuthFlow enum for consistency by comparing
settings.hub.auth.flow != AuthFlow.client, ensuring AuthFlow is imported or
referenced the same way as other checks (see existing comparisons to
AuthFlow.password and AuthFlow.client) so the module consistently uses the enum
values.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: f4432cfc-54af-46be-a9d3-8d30be7fc7fd

📥 Commits

Reviewing files that changed from the base of the PR and between ec4fefb and 753462f.

📒 Files selected for processing (7)
  • project/dependencies.py
  • project/routers/intermediate.py
  • project/routers/local.py
  • tests/conftest.py
  • tests/test_intermediate.py
  • tests/test_local.py
  • tests/test_local_tagged.py

Comment thread project/dependencies.py Outdated
@pbrassel pbrassel merged commit 0c0e737 into main Apr 16, 2026
3 checks passed
@pbrassel pbrassel deleted the enhance-intermediate-upload-response branch April 16, 2026 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant