FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Snapshot lookup by zone ignores the zone in its fallback (stray semicolon) · Issue #14770 · apache/cloudstack · GitHub

Repository navigation

Snapshot lookup by zone ignores the zone in its fallback (stray semicolon) #14770

Open

Description

problem

SnapshotDataFactoryImpl.getSnapshot(snapshotId, role, zoneId, retrieveAnySnapshotFromVolume) (used by getSnapshotWithRoleAndZone) has a stray ; in its fallback loop:

if (zoneId == storeMgr.getStoreZoneId(ref.getDataStoreId(), ref.getRole())); {
    snapshotStore = ref;
    break;
}
Effect
fallback loop the if is a no-op, so the first copy of the snapshot from any zone is returned
both loops long == Long unboxes; if getStoreZoneId returns null (it does when the primary pool lookup throws) this is an NPE

Came in with #7873. Present on 4.22 and main.

versions

4.19 onward, 4.22, main.

The steps to reproduce the bug

  1. Have a snapshot whose only copy is in zone A.
  2. Call anything that looks it up with getSnapshotWithRoleAndZone(id, role, zoneB).
  3. The zone A copy is returned instead of null.

What to do about it?

Remove the ; and compare null-safely in both loops.

Activity

  1. github-actions commented on Nov 26, 2026

    Warning

    threat detection engine error
    The threat detection engine encountered an error and could not complete analysis. This is a tooling failure, not a security finding.

    What happened

    The threat detection engine failed to produce results.

    Review the workflow run logs for details.

    🎯 Triage report

    SnapshotDataFactoryImpl.getSnapshot has a stray semicolon after the zone check in its fallback loop, so the if never applies and the first copy of the snapshot from any zone is returned. Both loops also compare long with Long, which can throw an NPE when getStoreZoneId returns null. The reporter says this came in with #7873 and is present on 4.19 onward.

    📊 Assessment

    Dimension Value Reasoning
    Type type:bug Wrong result from a lookup that is meant to filter by zone
    Component component:snapshot SnapshotDataFactoryImpl snapshot lookup
    Severity Severity:Minor Only affects the fallback path; the wrong zone copy is returned, with no data loss reported
    Labels type:bug, component:snapshot, Severity:Minor
    Coding agent Suitable Fix is specified: remove the semicolon and compare null-safely in both loops

    🔗 Similar issues

    💡 Notes and suggestions
    • Reproduction: a snapshot with its only copy in zone A, then getSnapshotWithRoleAndZone for zone B. Expect null.
    • Check whether the NPE path is reachable when the primary pool lookup throws.

    Generated by Daily Issue Triage · copilot · haiku55 · ~7 AIC · ⊞ 3.8K · ◷

    Add this agentic workflow to your repo

    To install this agentic workflow, run

    gh aw add githubnext/agentics/workflows/daily-issue-triage.md@139fa09ef17cde4135e696ff8e7af09bc5ddfa6e
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL