Skip to content

fix(BA-4624): Validate cloud detection responses and harden metadata JSON parsing#9653

Merged
HyeockJinKim merged 5 commits intomainfrom
fix/BA-4626
Mar 6, 2026
Merged

fix(BA-4624): Validate cloud detection responses and harden metadata JSON parsing#9653
HyeockJinKim merged 5 commits intomainfrom
fix/BA-4626

Conversation

@seedspirit
Copy link
Contributor

@seedspirit seedspirit commented Mar 5, 2026

resolves BA-4624

Checklist: (if applicable)

  • Milestone metadata specifying the target backport version
  • Mention to the original issue
  • Installer updates including:
    • Fixtures for db schema changes
    • New mandatory config options
  • Update of end-to-end CLI integration tests in ai.backend.test
  • API server-client counterparts (e.g., manager API -> client SDK)
  • Test case(s) to:
    • Demonstrate the difference of before/after
    • Demonstrate the flow of abstract/conceptual models with a concrete implementation
  • Documentation
    • Contents in the docs directory
    • docstrings in public interfaces and type annotations

@github-actions github-actions bot added size:L 100~500 LoC comp:common Related to Common component labels Mar 5, 2026
seedspirit added a commit that referenced this pull request Mar 5, 2026
@seedspirit seedspirit changed the title fix(BA-4626): Validate cloud detection responses and harden metadata JSON parsing fix(BA-4624): Validate cloud detection responses and harden metadata JSON parsing Mar 5, 2026
@seedspirit seedspirit requested a review from a team March 5, 2026 04:05
@seedspirit seedspirit marked this pull request as ready for review March 5, 2026 04:05
Copilot AI review requested due to automatic review settings March 5, 2026 04:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR hardens cloud-provider detection and instance metadata parsing to avoid false positives when running on non-major cloud providers, and adds unit tests to cover the new validation behavior.

Changes:

  • Validate AWS/Azure/GCP IMDS responses in _detect_* functions and tighten detect_cloud() timeouts/logging.
  • Make instance metadata JSON parsing resilient to empty/invalid payloads across AWS/Azure/GCP helpers.
  • Add unit tests for IMDS detection and JSON parsing fallbacks; add a towncrier fix fragment.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
tests/unit/common/test_identity.py Adds new unit tests for cloud detection validation and metadata parsing fallback paths.
src/ai/backend/common/identity.py Implements IMDS response validation, tighter client timeouts, and safer JSON parsing for instance metadata helpers.
changes/9653.fix.md Adds a release note fragment describing the fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

@seedspirit seedspirit added this to the 25.15 milestone Mar 5, 2026
seedspirit added a commit that referenced this pull request Mar 5, 2026
@github-actions github-actions bot added size:XL 500~ LoC and removed size:L 100~500 LoC labels Mar 5, 2026
assert ret == "default"


_AWS_URL = "http://169.254.169.254/latest/meta-data/"
Copy link
Member

Choose a reason for hiding this comment

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

This change is not part of this PR, but it would be better to extract 169.254.169.254 into a variable instead of repeating it.

HyeockJinKim
HyeockJinKim previously approved these changes Mar 5, 2026
@HyeockJinKim
Copy link
Collaborator

Please check the CI test. @seedspirit

@HyeockJinKim HyeockJinKim merged commit 1ece06f into main Mar 6, 2026
23 checks passed
@HyeockJinKim HyeockJinKim deleted the fix/BA-4626 branch March 6, 2026 05:50
lablup-octodog pushed a commit that referenced this pull request Mar 6, 2026
…JSON parsing (#9653)

Backported-from: main (26.2)
Backported-to: 26.2
Backport-of: 9653
lablup-octodog pushed a commit that referenced this pull request Mar 6, 2026
…JSON parsing (#9653)

Backported-from: main (26.2)
Backported-to: 25.15
Backport-of: 9653
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp:common Related to Common component size:XL 500~ LoC

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants