Fix IBM Schematics API compatibility issue#1006
Conversation
The list_locations() method was removed from IBM Schematics SDK. Replace dynamic location discovery with hardcoded known IBM Cloud regions. Fixes AttributeError: 'SchematicsV1' object has no attribute 'list_locations'
📝 WalkthroughSummary by CodeRabbit
Walkthrough
ChangesIBM Schematics region discovery refactor
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py`:
- Around line 54-62: The exception handling in the loop that iterates through
known_regions silently ignores all failures and returns an empty resources_list,
which downstream code interprets as "no workspaces found" rather than a genuine
failure. Add logging for each caught exception to track partial failures,
maintain a counter or flag to track whether any region query succeeded, and
after the loop completes, check if no regions were successfully queried and
raise an exception instead of returning the empty resources_list. This ensures
the calling code can distinguish between legitimate "no workspaces" and actual
connectivity or authentication issues that prevented any region from being
checked.
🪄 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: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 0d236c55-d756-4ef3-a573-358ac3a0fae4
📒 Files selected for processing (1)
cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py
- Track failed regions instead of silently ignoring all errors - Raise RuntimeError if ALL regions fail (prevents silent failures) - Include detailed error messages for debugging - Addresses CodeRabbit review feedback Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
♻️ Duplicate comments (1)
cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py (1)
62-76: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick winSurface partial region failures before returning.
If one region succeeds and another fails,
failed_regionsis discarded and callers receive partial workspace data as if it were complete. At minimum log these failures beforereturn; preferably catch the IBM SDK API exception type rather than blindException. This is the still-relevant partial-failure part of the previous review.#!/bin/bash # Description: verify available IBM SDK exception types and existing logger conventions before narrowing/logging. # Expected: identify the SDK API exception import to use here and the project's preferred logger pattern. rg -nP -C3 'ApiException|ibm_cloud_sdk_core|logging|getLogger|logger' --glob '*.py'🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py` around lines 62 - 76, The partial-failure handling in the Schematics workspace listing still drops information when some regions succeed and others fail. In the region-loop around the exception handling and the final return in the workspace listing function, surface any collected failed_regions before returning partial resources by logging them with the project’s existing logger pattern, and then keep returning the successful results. Also narrow the broad except Exception as exc to the IBM SDK API exception type used elsewhere in this module if available, so the failure tracking in failed_regions is more precise.Source: Linters/SAST tools
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py`:
- Around line 62-76: The partial-failure handling in the Schematics workspace
listing still drops information when some regions succeed and others fail. In
the region-loop around the exception handling and the final return in the
workspace listing function, surface any collected failed_regions before
returning partial resources by logging them with the project’s existing logger
pattern, and then keep returning the successful results. Also narrow the broad
except Exception as exc to the IBM SDK API exception type used elsewhere in this
module if available, so the failure tracking in failed_regions is more precise.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Enterprise
Run ID: 0bc7c433-90fb-4464-b7df-cc8900b10388
📒 Files selected for processing (1)
cloud_governance/common/clouds/ibm/developer_tools/schematic_operations.py
Type of change
Note: Fill x in []
Description
The list_locations() method was removed from IBM Schematics SDK. Replace dynamic location discovery with hardcoded known IBM Cloud regions. Fixes AttributeError: 'SchematicsV1' object has no attribute 'list_locations'
For security reasons, all pull requests need to be approved first before running any automated CI
Assisted-by: Cursor