Skip to content

fix(examples): return an error for missing image data - #1509

Merged
wolo-lab merged 4 commits into
google:mainfrom
ktsoator:fix/image-save-missing-data
Oct 3, 2026
Merged

wolo-lab merged 4 commits into
google:mainfrom
ktsoator:fix/image-save-missing-data

Conversation

@ktsoator

@ktsoator ktsoator commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Link to Issue or Description of Change

1. Link to an existing issue (if applicable):

Problem:

save_image_locally detected artifacts without usable inline data but returned
the stale error value from the preceding successful artifact load. Because that
error was nil, the tool invocation could be treated as successful even though
no image was written.

Solution:

Return a descriptive error when the loaded artifact has no InlineData or its
inline payload is empty.

Add tests using the in-memory artifact service for both missing-data shapes and
verify that artifact load errors continue to be returned unchanged.

Behavior change

Calling save_image_locally with an artifact that has no usable inline data now
returns a non-nil error instead of an empty result with a nil error.

Testing Plan

Unit Tests:

  • All unit tests pass locally.

With the source change reverted, TestSaveImageRejectsMissingInlineData fails
for both nil inline data and empty inline data because saveImage returns a
nil error.

Commands completed successfully:

  • go test -race -count=1 ./examples/vertexai/imagegenerator
  • go build -mod=readonly work
  • go test -race -mod=readonly -count=1 -shuffle=on work
  • go vet ./examples/...
  • golangci-lint run with the CI-pinned v2.3.1 in both modules
  • go mod tidy -diff in both modules
  • golangci-lint fmt -d with the CI-pinned v2.3.1 in both modules

Manual End-to-End (E2E) Tests:

Not run. This failure path does not require a live model or API request and is
covered offline using the real in-memory artifact service.

Checklist

  • I have read the CONTRIBUTING.md document.
  • I have performed a self-review of my own code.
  • I have commented my code where necessary.
  • I have added tests that prove my fix is effective.
  • New and existing unit tests pass locally with my changes.
  • I have manually tested my changes end-to-end.
  • Any dependent changes have been merged and published in downstream modules.

Additional context

This is separate from #1477, which covers validation of image-generation API
responses before saving an artifact. This change concerns loading an existing
artifact in save_image_locally.

Return a descriptive error when save_image_locally loads an artifact without usable inline data instead of returning the stale nil load error.

Add tests for nil and empty inline data, and verify that artifact load errors remain unchanged.

Fixes google#1508

@wolo-lab wolo-lab left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, thanks

@wolo-lab
wolo-lab merged commit 8455828 into google:main Oct 3, 2026
14 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.

examples/vertexai/imagegenerator: save_image_locally returns a nil error when image data is missing

2 participants