Skip to content

put step succeeds and swallows the error from faulty resource types #9632

Closed

Description

@aliculPix4D

Summary

From v8.X Concourse (#9293) doesn't allow (faulty) resource types to store empty versions in the database. This is correct and the desired behaviour. But if one tries to use a faulty resource type (e.g one that emits the now forbidden empty version like {"version": {} }) in the put step, Concourse will not surface the error message to the pipeline operator and it will just swallow the error, with put step finishing with success.. The actual version will, of course, never be stored in the database.

The actual error message is correctly shown in ATC logs (seen by the Concourse operator), but the issue can create great confusion for the pipeline operator.

In short we should not just swallow the error and let the put step succeed.

    if err != nil {
        logger.Error("failed-to-save-output", err)
        return   // <-- error swallowed; put step continues as success
    }

Instead, the put step should fail, and an error message should be surfaced to the pipeline operator.

What is even worse with this bug is that the resource put step actually managed to upload the files to S3, making the issue even more confusing to debug. See the example pipeline below: build will be green, files will be in S3; hence it's easy to conclude everything works fine, until one looks at the ATC logs (or tries to connect this resource with passed constrain with another job)

error{
  "level": "error",
  "source": "atc",
  "message": "atc.tracker.notify.run.put-step.failed-to-save-output",
  "data": {
    "error": "resource output version is empty. Version must contain at least one key-value pair",
    "job": "upload-artifact",
    "pipeline": "test-s3-simple",
    "resource": "bucket.s3simple",
    "resource-type": "s3-resource-simple",
    "step": "bucket.s3simple",
    "step-name": "bucket.s3simple",
    "version": {}
  }
}

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": }

Steps to Reproduce

  1. set this pipeline (configure your AWS credentials)
resource_types:
- name: s3-resource-simple
  type: registry-image
  source:
    repository: pix4d/s3-resource-simple
    tag: emptyversion

resources:
- name: bucket.s3simple
  type: s3-resource-simple
  check_every: never
  source:
    bucket: your-aws-s3-bucket-name
    region_name: ((aws_region_name))
    access_key_id: ((aws_access_key_id))
    secret_access_key: ((aws_secret_access_key))
    path: s3-resource-simple/test/
    sync: false
    put_options:
      - --recursive

jobs:
- name: upload-artifact
  plan:
  - task: create-artifact
    config:
      platform: linux
      image_resource:
        type: registry-image
        source:
          repository: busybox
      outputs:
      - name: out
      run:
        path: sh
        args:
        - -c
        - |
          set -e
          ts=$(date +%Y-%m-%d_%H:%M:%S)
          mkdir -p out/dir1/dir2
          touch out/witness-0-$ts
          touch out/dir1/witness-1-$ts
          touch out/dir1/dir2/witness-2-$ts
          echo "hello-$ts" > out/hello.txt
  - put: bucket.s3simple
    inputs: [out]
    no_get: true
    params:
      dir: out
  1. build will succeed (put step also); files will be uploaded to s3
  2. inspect the ATC logs and database; the version will not be stored. Expect to see the following error: resource output version is empty. Version must contain at least one key-value pair in ATC logs. That is what we want, but we want also the put step to fail.

Expected Results

The put step should fail if it didn't manage to store the version (e.g Concourse rejected the empty version). The meaningful and useful error message should be printed to the user in the build logs explaining why the put step failed.

Actual Results

Put step succeeds, new version is not stored in the database, but the artifacts are uploaded to S3. Requires the Concourse operator to inspect the ATC logs and inform the pipeline operator. Additionally, the issue is difficult to understand and debug in large pipelines where there is passed constrain with trigger on the the 2nd job.

Part of the code of interest:

atc/engine/put_delegate.go
Lines 87-107

func (d *putDelegate) SaveOutput(log lager.Logger, plan atc.PutPlan, source atc.Source, imageResourceCache db.ResourceCache, info resource.VersionResult) {
    // ...
    err := d.build.SaveOutput(/* ... */, info.Version, /* ... */)
    if err != nil {
        logger.Error("failed-to-save-output", err)
        return   // <-- error swallowed; put step continues as success
    }
}

resulting in ATC logs

error{
  "level": "error",
  "source": "atc",
  "message": "atc.tracker.notify.run.put-step.failed-to-save-output",
  "data": {
    "error": "resource output version is empty. Version must contain at least one key-value pair",
    "resource": "concourse.s3",
    "resource-type": "s3-simple",
    "version": {}
  }
}

but with put step successful.

The following part of the code is responsible for the confusing error from json.unmarshal

atc/resource/resource.go
Lines 88-93 and 105-107

if result := properties[resultCachePropertyName]; result != "" {
    if err := json.Unmarshal([]byte(result), &versionResult); err != nil {
        return VersionResult{}, runtime.ProcessResult{}, err
    }
    return versionResult, runtime.ProcessResult{}, nil
}

if processResult.ExitStatus == 0 && versionResult.Version == nil {
    return VersionResult{}, runtime.ProcessResult{}, fmt.Errorf("resource script (%s %s) output a null version", spec.Path, strings.Join(spec.Args, " "))
}

The same issue with json.Unmarshalcan occur in get step part...

Concourse Version

v8.2.4

Additional information:

In the last year or so, we have seen many issues due to faulty resources emitting the empty (or sometimes even null) versions.

Some discussions:

And everyone always wonder how that was possible

So I finally found at least one culprit. It is called s3-simple-resource or sometimes s3-resource simple, and there are many forks of it.

e.g.

  1. https://github.com/cloud-gov/s3-simple-resource
  2. https://github.com/da1nerd/s3-resource-simple
  3. our Pix4D fork: https://github.com/Pix4D/s3-resource-simple

but I noticed many more docker images from other authors referencing it.

What is the problem with this resource? There are a few actually:

Concourse rightfully assumed all resource types are well-behaved and respect the resource type design and contract. Developers on the other hand, will do everything just to quickly achieve what they need :)

Note also that "version" doesn't really make a lot of sense with this resource type: What is the version if you upload multiple files at once? What is the version if you didn't upload any file? On top of that this resource type is often used only as "put-only" resource.

See my 2 PRs to improve this resource a bit in our fork so that it works with Concourse v8.X

  1. make check/get/put to emit a consistent non-empty version: don't emit emtpy version; make check/get/put consitent version wise Pix4D/s3-resource-simple#18
  2. handle corner cases and emit the version even if nothing was uploaded out script: we MUST emit a version even when we don't upload anything Pix4D/s3-resource-simple#21

To conclude, this is only 1 resource type example that does this, but there might be more. It would be perfect if in the long run Concourse would require the resource types to register with ATC before they can be used, and that it enforces/ensures that registered resource types respect the contract (version key/value is consistent in each step, and only valid source/params are configured), but this is the story for some other time.

Activity

  1. aliculPix4D commented on Jul 7, 2026

    @aliculPix4D
    ContributorAuthor

    @IvanChalukov, you will be interested in this one since we finally know which resource type was putting those empty versions to the database :)

  2. Kump3r commented on Jul 27, 2026

    @Kump3r
    Contributor

    I updated my review comment with some testing details. Thank you for fixing this the I merged the PR, but since you mention: "In the follow-up PR, we can improve the confusing error messages from the JSON decoder.", but I was not able to find it, do you need the issue still, or can we close it as completed?

  3. aliculPix4D commented on Jul 27, 2026

    @aliculPix4D
    ContributorAuthor

    I updated my review comment with some testing details. Thank you for fixing this the I merged the PR, but since you mention: "In the follow-up PR, we can improve the confusing error messages from the JSON decoder.", but I was not able to find it, do you need the issue still, or can we close it as completed?

    The follow up PR doesn't exist yet :) I wanted to wait for the review on the first PR first. Now that the first PR is merged, I will prepare the follow-up one.

    Regarding this issue, I think we can close it. The actual bug is fixed. The follow-up is just about giving a clearer error message in some additional corner cases.

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions