Skip to content

Fix invalid optional access in GetHostBuild#2241

Merged
Databean merged 1 commit intogoogle:mainfrom
Databean:cvd_load_optional
Mar 10, 2026
Merged

Fix invalid optional access in GetHostBuild#2241
Databean merged 1 commit intogoogle:mainfrom
Databean:cvd_load_optional

Conversation

@Databean
Copy link
Copy Markdown
Member

@Databean Databean commented Mar 9, 2026

The expression host_package_build.value_or(*fallback_host_build); to select between two optionals after knowing one is set is invalid. In the case where fallback_host_build is missing and host_package_build is present, fallback_host_build is still dereferenced to supply the argument to value_or, even if it is ignored by the implementation.

Issue observed by dsk@ using the following configuration to cvd load:

{
  "common": {
    "host_package": "@ab/aosp-android-latest-release/aosp_cf_x86_64_only_phone-userdebug"
  },
  "instances": [
    {
      "disk": {
        "default_build": "14981173"
      },
      "name": "ins-1",
      "vm": {
        "cpus": 4,
        "memory_mb": 4096
      }
    }
  ],
  "metrics": {
    "enable": true
  }
}

Bug: b/491203837

@Databean Databean requested a review from 3405691582 March 9, 2026 22:36
@Databean Databean enabled auto-merge March 9, 2026 22:37
@Databean Databean added the kokoro:run Run e2e tests. label Mar 9, 2026
@GoogleCuttlefishTesterBot GoogleCuttlefishTesterBot removed the kokoro:run Run e2e tests. label Mar 9, 2026
Comment thread base/cvd/cuttlefish/host/commands/cvd/fetch/fetch_cvd.cc Outdated
The expression `host_package_build.value_or(*fallback_host_build);` to
select between two optionals after knowing one is set is invalid. In the
case where `fallback_host_build` is missing and `host_package_build` is
present, `fallback_host_build` is still dereferenced to supply the
argument to `value_or`, even if it is ignored by the implementation.

Issue observed by dsk@ using the following configuration to `cvd load`:
```
{
  "common": {
    "host_package": "@ab/aosp-android-latest-release/aosp_cf_x86_64_only_phone-userdebug"
  },
  "instances": [
    {
      "disk": {
        "default_build": "14981173"
      },
      "name": "ins-1",
      "vm": {
        "cpus": 4,
        "memory_mb": 4096
      }
    }
  ],
  "metrics": {
    "enable": true
  }
}
```

Bug: b/491203837
@Databean Databean force-pushed the cvd_load_optional branch from 84ec51e to 53a3b4d Compare March 10, 2026 18:14
@Databean
Copy link
Copy Markdown
Member Author

Thanks for reviewing!

@Databean Databean added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
@Databean Databean added this pull request to the merge queue Mar 10, 2026
Merged via the queue into google:main with commit 09b929b Mar 10, 2026
26 checks passed
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.

3 participants