Skip to content

var_sources not accessible when inside an across task #8191

Closed

Description

@farhank3389

Summary

I have 2 dummy var_sources defined. I am using across to iterate over one of the dummy vars but I get the following error when trying to also access the other dummy var inside the task. The same thing happens with accessing vault var_sources inside across.

failed to interpolate template: missing source 'dummyvar2' in var: dummyvar2:testkey

Steps to reproduce

Create and run the following pipeline:

var_sources:
- name: dummyvar
  type: dummy
  config:
    vars:
      testkey: ["test1", "test2"]
- name: dummyvar2
  type: dummy
  config:
    vars:
      testkey: "test3"

jobs:
- name: placeholder
  plan:
  - across:
    - var: testiter
      values: ((dummyvar:testkey))
    task: use-vars
    config:
      platform: linux

      image_resource:
        type: mock
        source: {mirror_self: true}

      run:
        path: sh
        args:
        - -exc
        - |
          echo ((.:testiter))
          echo ((dummyvar2:testkey))

Running this without echo ((dummyvar2:testkey)) works fine - it iterates over testkey and echoes test1 and test2.

Expected results

The task should be able to access the other variable.

Actual results

This error is produced when running the pipeline

failed to interpolate template: missing source 'dummyvar2' in var: dummyvar2:testkey

Triaging info

  • Concourse version: v7.7.0
  • Browser (if applicable): Chromium
  • Did this used to work? Don't know

Activity

  1. timota commented on Mar 30, 2022

    @timota

    Actually issue that var_sources are not rendered if called inside across step. As an example:

    var_sources:
    - name: secrets
      type: vault
      config:
        url: https://url
        path_prefix: concourse
        shared_path: shared
        auth_backend: approle
        auth_params:
          role_id: ((role_id))
          secret_id: ((secret_id))
        lookup_templates:
          - "/{{.Team}}/{{.Pipeline}}/{{.Secret}}"
          - "/{{.Team}}/{{.Secret}}"
          - "/{{.Secret}}"
    
    ---
    # some resources, steps are omitted 
    # important steps are defined below
    ---
    
      - load_var: images
        file:docker-images/by_tags.yml
    
      - across:
        - var: image
          values: ((.:images))
          max_in_flight: 1
        task: set-repo
        image: task-runner
        file: pps/tasks/test-var.yml
        params:
          AWS_ACCESS_KEY_ID: ((secrets:ecr.access-key-id))
          AWS_SECRET_ACCESS_KEY: ((secrets:ecr.secret-access-key))
    

    in this case params could not be interpolated with an error

    failed to interpolate template: missing source 'secrets' in var: secrets:ecr.access-key-id
    

    same happened when you define script in-line (same as original snippet above this post).

    BUT

    when params are defined in file: pps/tasks/test-var.yml ONLY - they are interpolated and rendered properly. eg:

    # part of pipeline
      - across:
        - var: image
          values: ((.:images))
          max_in_flight: 1
        task: set-repo
        image: task-runner
        file: pps/tasks/test-var.yml
    
    ---
    
    # Dynamic task script: pps/tasks/test-var.yml
    
    platform: linux
    params:
      AWS_ACCESS_KEY_ID: ((secrets:ecr.access-key-id))
      AWS_SECRET_ACCESS_KEY: ((secrets:ecr.secret-access-key))
    

    Looks like something broken during pipeline processing, but works if all secrets used/defined inside dynamic task file.

  2. timota commented on Jun 22, 2022

    @timota

    any updates on this issue ?
    it completely eliminates benefits of var_sources

  3. iomarcovalente commented on Jun 23, 2022

    @iomarcovalente
  4. schmurfy commented on Jul 2, 2024

    @schmurfy
    Contributor

    I finally tried across and stumbled on this, now I am sad :(

    Across is a really nice feature.

  5. taylorsilva commented on Jan 7, 2025

    @taylorsilva
    Member

    Leaving this open, we should still get this fixed. Not on the roadmap. Anyone is free to make a PR fixing this, I'll review it.

  6. taylorsilva commented on Jul 30, 2025

    @taylorsilva
    Member

    Having trouble finding the code right now, but the issue is likely with the "var scope" setup when running the across step. We must be forgetting to pull in the var_sources when creating the "local scope" for the across sub-steps, or something like that. Like I said, can't find the code relevant code right now so this won't make sense to anyone else except future me 😅 This is mostly a note for my future self.

  7. taylorsilva commented on Jul 30, 2025

    @taylorsilva
    Member

    Ah, this might be the general area to start looking at:

    // Even though we interpolate the vars into the substep plan, we
    // still need to add them to a local scope since they can be used
    // to interpolate a task file.
    scope := state.NewLocalScope()

  8. added 2 commits that reference this issue on Apr 12, 2026
    efc1670
    aef8b69
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions