Skip to content

Fail put step when saving output fails - #9658

Merged
Kump3r merged 1 commit into
concourse:masterfrom
Pix4D:issue-9632-put-step
Jul 27, 2026
Merged

Kump3r merged 1 commit into
concourse:masterfrom
Pix4D:issue-9632-put-step

Conversation

@aliculPix4D

@aliculPix4D aliculPix4D commented Jul 23, 2026 •

Copy link
Copy Markdown
Contributor

Fail a put-step when saving output does not succeed.

  • propagate SaveOutput errors so that put steps do not succeed when their resource version cannot be persisted.

To confirm that this was fixed, I just created the pipeline as explained in the issue section: steps to reproduce.

Here are the logs from my tests.

  1. run from master branch:
selected worker: b2b6554cdd58
Uploading to S3 from dir=out ...
Running: aws s3 cp /tmp/build/put/out "s3://concourse/s3-resource-simple/test/" 
upload: dir1/dir2/witness-2-2026-07-23_13:33:39 to s3://concourse/s3-resource-simple/test/dir1/dir2/witness-2-2026-07-23_13:33:39
upload: ./witness-0-2026-07-23_13:33:39 to s3://concourse/s3-resource-simple/test/witness-0-2026-07-23_13:33:39
upload: dir1/witness-1-2026-07-23_13:33:39 to s3://concourse/s3-resource-simple/test/dir1/witness-1-2026-07-23_13:33:39
upload: ./hello.txt to s3://concourse/s3-resource-simple/test/hello.txt
...done.
succeeded

$ docker compose -f docker-compose.yml -f hack/overrides/minio.yml logs web \
  | rg 'failed-to-save-output|put-step.finished|finish.succeeded'

web-1  | {"timestamp":"2026-07-23T13:33:52.943765545Z","level":"error","source":"atc","message":"atc.tracker.notify.run.put-step.failed-to-save-output","data":{"build":"5","build_id":5,"error":"resource output version is empty. Version must contain at least one key-value pair","job":"upload-artifact","job-id":1,"pipeline":"s3simple-minio","resource":"bucket.s3simple","resource-type":"s3-resource-simple","session":"27.7.2.19","step":"bucket.s3simple","step-name":"bucket.s3simple","team":"main","version":{}}}
web-1  | {"timestamp":"2026-07-23T13:33:52.944451919Z","level":"info","source":"atc","message":"atc.tracker.notify.run.put-step.finished","data":{"build":"5","build_id":5,"exit-status":0,"job":"upload-artifact","job-id":1,"pipeline":"s3simple-minio","session":"27.7.2.19","step-name":"bucket.s3simple","team":"main","version-info":{"version":{}}}}
web-1  | {"timestamp":"2026-07-23T13:33:52.952853046Z","level":"info","source":"atc","message":"atc.tracker.notify.run.finish.succeeded","data":{"build":"5","build_id":5,"job":"upload-artifact","pipeline":"s3simple-minio","session":"27.7.2.35","team":"main"}}

shows that in ATC logs that the put step errored and failed to save the version to the database, while the user is informed that the put-step succeeded.

2 .run from PR branch:

selected worker: f550a79daec7
Uploading to S3 from dir=out ...
Running: aws s3 cp /tmp/build/put/out "s3://concourse/s3-resource-simple/test/" 
upload: dir1/dir2/witness-2-2026-07-23_13:28:39 to s3://concourse/s3-resource-simple/test/dir1/dir2/witness-2-2026-07-23_13:28:39
upload: ./witness-0-2026-07-23_13:28:39 to s3://concourse/s3-resource-simple/test/witness-0-2026-07-23_13:28:39
upload: dir1/witness-1-2026-07-23_13:28:39 to s3://concourse/s3-resource-simple/test/dir1/witness-1-2026-07-23_13:28:39
upload: ./hello.txt to s3://concourse/s3-resource-simple/test/hello.txt
...done.
resource output version is empty. Version must contain at least one key-value pair
errored

$ docker compose -f docker-compose.yml -f hack/overrides/minio.yml logs web \
  | rg 'failed-to-save-output|put-step.finished|finish.succeeded'
  
web-1  | {"timestamp":"2026-07-23T13:28:51.539431225Z","level":"error","source":"atc","message":"atc.tracker.notify.run.put-step.failed-to-save-output","data":{"build":"4","build_id":4,"error":"resource output version is empty. Version must contain at least one key-value pair","job":"upload-artifact","job-id":1,"pipeline":"s3simple-minio","resource":"bucket.s3simple","resource-type":"s3-resource-simple","session":"27.26.2.22","step":"bucket.s3simple","step-name":"bucket.s3simple","team":"main","version":{}}}

and we can see that both ATC logs and user have the same information; put step did not succeed.

The main problem described in: #9632 has been resolved by this PR. The put step will not silently succeed.

In the follow-up PR, we can improve the confusing error messages from the JSON decoder.

Note that there is a 2nd variation of the same issue, where the put step fails, but the error message is confusing (error: invalid character '}' looking for beginning of value) and not very useful or understandable by everyone. It can occur if the resource emits a version like: {"version": }

- propagate SaveOutput errors so put steps do not succeed when their resource version cannot be persisted.
@Kump3r Kump3r self-assigned this Jul 27, 2026
@Kump3r
Kump3r self-requested a review July 27, 2026 13:55
@Kump3r Kump3r assigned aliculPix4D and unassigned Kump3r Jul 27, 2026

@Kump3r Kump3r 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.

Clean, minimal fix for a real correctness bug - SaveOutput errors were previously swallowed silently, causing builds to appear successful while the output version was never recorded. The change is well-scoped, follows existing conventions, and the test coverage is thorough (error propagated, step not successful, Finished/StoreResult not called).

Worth noting for operators: builds that previously succeeded silently on a DB error during SaveOutput will now be marked as errored. This is the correct behaviour, but may surface as new alerts in production after rollout.

Tests:

I did a before and after with the following Dockerfile:

FROM busybox
RUN mkdir -p /opt/resource
RUN echo '#!/bin/sh' > /opt/resource/check && echo 'echo "[]"' >> /opt/resource/check && chmod +x /opt/resource/check
RUN echo '#!/bin/sh' > /opt/resource/in && echo 'echo "{}"' >> /opt/resource/in && chmod +x /opt/resource/in
RUN echo '#!/bin/sh' > /opt/resource/out &&  echo 'echo "{\"version\": {}}"' >> /opt/resource/out && chmod +x /opt/resource/out

Before:

Image

After:

Image

@Kump3r
Kump3r merged commit 9da61c7 into concourse:master Jul 27, 2026
11 checks passed
@aliculPix4D

Copy link
Copy Markdown
Contributor Author

@Kump3r Thanks for the review and taking care of this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants