Skip to content

Conversation

@rawagner
Copy link
Member

@rawagner rawagner commented Aug 6, 2025

lightspeed is now formatting the tool_call responses are JSON. Lets do the same for Assisted MCP presigned_url responses. Others may follow.

Summary by CodeRabbit

  • New Features

    • Download URLs for ISO images and cluster credentials are now returned as JSON objects, providing structured information including the URL and optional expiration time.
  • Bug Fixes

    • Expiration times for presigned URLs are now consistently formatted in ISO 8601 with UTC indication.
  • Tests

    • Updated tests to validate the new JSON response format for download URLs and credentials.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 6, 2025

@rawagner: This pull request references MGMT-21339 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

lightspeed is now formatting the tool_call responses are JSON. Lets do the same for Assisted MCP responses.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot openshift-ci-robot added the jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. label Aug 6, 2025
@openshift-ci openshift-ci bot requested review from jhernand and omertuc August 6, 2025 11:55
@coderabbitai
Copy link

coderabbitai bot commented Aug 6, 2025

Walkthrough

The changes update the output format of presigned URL-related functions in server.py from plain strings to JSON-encoded dictionaries or lists. Function signatures and docstrings are adjusted accordingly. Tests are updated to expect JSON outputs, and a test utility is modified to ensure expires_at is a datetime object instead of a string.

Changes

Cohort / File(s) Change Summary
Presigned URL Output Refactor
server.py
Functions format_presigned_url, cluster_iso_download_url, and cluster_credentials_download_url now return JSON-encoded dictionaries or lists instead of formatted strings. Return types and docstrings updated to match new output.
Test Output Format Update
tests/test_server.py
Test assertions for URL download functions updated to expect JSON-encoded outputs. Expected results changed from plain strings to JSON objects/arrays reflecting new output structure.
Test Utility Adjustment
tests/test_utils.py
The create_test_presigned_url helper now parses the expires_at parameter into a datetime object, ensuring correct type for test data.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant Models

    Client->>Server: Request ISO/credentials download URL
    Server->>Models: Retrieve PresignedUrl object(s)
    Server->>Server: format_presigned_url(presigned_url)
    Server->>Client: Return JSON-encoded dict/list with "url" and "expires_at"
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

  • Refresh the ISO URL when returning it #31: Both PRs modify the format_presigned_url function, with this PR evolving its output from a formatted string to a structured dictionary, indicating a direct relationship.

Suggested labels

size/L, lgtm

Poem

A bunny hopped through code with glee,
Transforming URLs for all to see.
No more strings, just JSON neat,
With "expires_at" and URLs sweet.
Tests now check the structured way—
Hippity-hop, code’s bright today!
🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a426855 and a1bbba4.

📒 Files selected for processing (3)
  • server.py (6 hunks)
  • tests/test_server.py (7 hunks)
  • tests/test_utils.py (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Red Hat Konflux / assisted-service-mcp-saas-main-on-pull-request
🔇 Additional comments (16)
tests/test_utils.py (2)

5-5: LGTM: Import addition supports datetime handling.

The datetime import is correctly added to support the conversion of expires_at from ISO string to datetime object.


88-96: LGTM: Proper datetime conversion for test consistency.

The function correctly converts the expires_at parameter from an ISO 8601 string to a datetime object using fromisoformat(). This ensures the test utility creates objects that match the expected data structure in the server implementation.

The logic properly handles the None case and uses the converted datetime object when constructing the PresignedUrl model.

tests/test_server.py (7)

374-382: LGTM: Test properly updated for JSON array output format.

The test correctly expects a JSON-encoded array containing an object with "url" and "expires_at" fields, matching the new output format from cluster_iso_download_url.


435-447: LGTM: Test correctly handles multiple infraenvs in JSON format.

The test properly expects a JSON array with multiple objects, each containing "url" and "expires_at" fields for multiple infrastructure environments.


481-488: LGTM: Test correctly handles missing expiration in JSON format.

The test appropriately expects a JSON array with an object containing only the "url" field when no expiration is provided, correctly omitting the "expires_at" field.


520-527: LGTM: Test properly handles zero/default expiration dates.

The test correctly expects a JSON array with an object containing only the "url" field when the expiration is a zero/default date, appropriately excluding the meaningless "expires_at" field.


854-860: LGTM: Cluster credentials test updated for JSON object format.

The test correctly expects a JSON object with "url" and "expires_at" fields, matching the new structured output format from cluster_credentials_download_url.


887-887: LGTM: Test correctly handles credentials without expiration.

The test appropriately expects a JSON object with only the "url" field when no expiration is provided for cluster credentials.


918-918: LGTM: Test handles zero expiration correctly for credentials.

The test properly expects a JSON object with only the "url" field when the expiration is a zero/default date for cluster credentials.

server.py (7)

11-11: LGTM: Import addition supports new type annotations.

The Any import is correctly added to support the new return type annotation for the format_presigned_url function.


29-29: LGTM: Function signature updated correctly.

The function signature is properly updated to return dict[str, Any] instead of a string, accurately reflecting the new structured output format.


37-56: LGTM: Well-implemented dictionary conversion with proper ISO formatting.

The implementation correctly:

  • Creates a dictionary with the presigned URL
  • Conditionally includes the expiration timestamp only when meaningful (not zero/default dates)
  • Properly formats the datetime as ISO 8601 with 'Z' suffix for UTC using isoformat().replace("+00:00", "Z")

The logic appropriately filters out meaningless default dates starting with "0001-01-01".


255-260: LGTM: Docstring accurately reflects new JSON array format.

The docstring is properly updated to document the new JSON-encoded array output format with "url" and optional "expires_at" fields.


300-300: LGTM: Function correctly returns JSON-encoded array.

The function now properly returns a JSON-encoded string of the iso_info list, which contains dictionaries formatted by format_presigned_url.


550-555: LGTM: Docstring updated to reflect JSON object format.

The docstring correctly documents the new JSON-encoded object output format with "url" and optional "expires_at" fields for cluster credentials.


571-571: LGTM: Function returns properly formatted JSON object.

The function correctly returns a JSON-encoded string of the dictionary created by format_presigned_url, maintaining consistency with the other updated functions.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@openshift-ci openshift-ci bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 6, 2025
@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 6, 2025

@rawagner: This pull request references MGMT-21339 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

lightspeed is now formatting the tool_call responses are JSON. Lets do the same for Assisted MCP presigned_url responses. Others may follow.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci-robot
Copy link

openshift-ci-robot commented Aug 6, 2025

@rawagner: This pull request references MGMT-21339 which is a valid jira issue.

Warning: The referenced jira issue has an invalid target version for the target branch this PR targets: expected the story to target the "4.20.0" version, but no target version was set.

In response to this:

lightspeed is now formatting the tool_call responses are JSON. Lets do the same for Assisted MCP presigned_url responses. Others may follow.

Summary by CodeRabbit

  • New Features

  • Download URLs for ISO images and cluster credentials are now returned as JSON objects, providing structured information including the URL and optional expiration time.

  • Bug Fixes

  • Expiration times for presigned URLs are now consistently formatted in ISO 8601 with UTC indication.

  • Tests

  • Updated tests to validate the new JSON response format for download URLs and credentials.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the openshift-eng/jira-lifecycle-plugin repository.

@openshift-ci openshift-ci bot added the lgtm Indicates that a PR is ready to be merged. label Aug 6, 2025
@openshift-ci
Copy link

openshift-ci bot commented Aug 6, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: carbonin, rawagner

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci openshift-ci bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 6, 2025
@openshift-merge-bot openshift-merge-bot bot merged commit 2beef39 into openshift-assisted:master Aug 6, 2025
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. jira/valid-reference Indicates that this PR references a valid Jira ticket of any type. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants