Skip to content

fix: return error when {{ source }} references a skipped source - #9095

Open
ambikeesshh wants to merge 9 commits into
updatecli:mainfrom
ambikeesshh:fix/source-template-skipped
Open

fix: return error when {{ source }} references a skipped source#9095
ambikeesshh wants to merge 9 commits into
updatecli:mainfrom
ambikeesshh:fix/source-template-skipped

Conversation

@ambikeesshh

@ambikeesshh ambikeesshh commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Fix #7919

Summary

{{ source "id" }} returns the literal string {{ source "id" }} when the referenced source is skipped via depends_on. Since a skipped source never transitions to SUCCESS, this template literal never resolves. It silently leaks into config values causing confusing downstream failures with no clear indication of what went wrong.

What changed

Sources initialized with Result: SKIPPED, same state as an explicitly skipped source, so the template function couldn't tell them apart. Two changes fix this:

  • Changed initial source result from result.SKIPPED to empty string, so "not yet run" and "skipped" are distinguishable
  • Set source result to SKIPPED explicitly when shouldSkipResource skips a source

Then the template function can safely error on SKIPPED:

  • Added case result.SKIPPED in the runtime source template function that returns a clear error, consistent with existing FAILURE handling

Test

go test ./pkg/core/config/... -run TestUpdate -v -count=1
go test ./pkg/core/pipeline/... -run TestRunSources -v -count=1

New test cases:

  • pkg/core/config/main_test.go - unit test for SKIPPED source in template function
  • pkg/core/pipeline/sources_test.go - end-to-end test with a source skipped via depends_on and a target referencing it via {{ source "..." }}

@ambikeesshh
ambikeesshh force-pushed the fix/source-template-skipped branch from 5fa3757 to 06f0a18 Compare June 2, 2026 12:30
@ambikeesshh

Copy link
Copy Markdown
Contributor Author

hey @olblak PTAL
thanks!!

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak can you review it ? when you get a chance

@olblak

olblak commented Jun 4, 2026

Copy link
Copy Markdown
Member

Of course, I'll try to find some time thanks for the fix

Comment thread pkg/core/pipeline/main.go Outdated
Config: config.Spec.Sources[id],
Result: &result.Source{
Result: result.SKIPPED,
Result: "",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is it changed from result.SKIPPED to empty string?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ok, now I understand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

empty string = not yet run (retry later). SKIPPED = explicitly skipped (error)
both were the same value before this change

@ambikeesshh
ambikeesshh force-pushed the fix/source-template-skipped branch from dfca649 to 8bf3606 Compare June 4, 2026 16:53
@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak rebased on latest main

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak friendly ping

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak

@olblak

olblak commented Jun 10, 2026

Copy link
Copy Markdown
Member

@ambikeesshh Sorry very busy days at work.
Have you seen my review?

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak yep, i replied inline on the Result: "" change. The empty string distinguishes "not yet run" from "explicitly skipped" so the template function can error on the latter.

lemme know if you'd like any other changes

Copilot AI 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.

Pull request overview

This pull request fixes a confusing failure mode where {{ source "id" }} could remain unresolved and silently leak into runtime configuration when the referenced source was skipped via depends_on. It makes “not yet run” distinguishable from “skipped”, and updates the runtime template behavior to return a clear error when a skipped source is referenced.

Changes:

  • Initialize sources with an empty result (instead of SKIPPED) so the runtime template engine can distinguish “pending” vs “skipped”.
  • Explicitly mark sources as SKIPPED when depends_on causes them to be skipped.
  • Update the runtime source template function to error when the referenced source is SKIPPED, and add/extend tests covering this behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
pkg/core/pipeline/sources_test.go Adds an end-to-end test ensuring a target referencing a skipped source via {{ source "..." }} fails clearly.
pkg/core/pipeline/main.go Changes initial source result to empty and explicitly sets SKIPPED when a source is skipped by dependency logic.
pkg/core/config/main_test.go Adds a unit test asserting the runtime template error message for a skipped source.
pkg/core/config/funcsUpdatecli.go Adds explicit SKIPPED handling in the runtime source template function, returning a clear error.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ambikeesshh
ambikeesshh requested a review from olblak June 10, 2026 18:04
@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak

@olblak

olblak commented Jun 15, 2026

Copy link
Copy Markdown
Member

@olblak

Hi @ambikeesshh,
I am reposting here what I post earlier in this pullrequest


I am a bit annoyed by this change because if something unexpected happened, the resource wouldn't have a clear state.
It's used, for example, on this webapp https://app.uda.sh/updatecli/scm/dashboard to monitor Updatecli dependencies.

I think I would prefer to add a new Boolean named "IsRun" on the source/condition/target like

type Source struct {

Once The source function is exectued like here

err = source.Source(ctx, workingDir, s.Result)

then we set it to true

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

hey @olblak
done, reworked it the way you suggested

  • dropped the empty Result, sources now init to SKIPPED like conditions/targets so the state stays valid
  • added IsRun to source/condition/target, set to true inside each Run() where you pointed

one note: a skipped source never hits Run(), so i set IsRun = true on the skip path too. so it means "ran or skipped". if you'd rather it strictly mean "executed", i'll use a separate flag instead. let me know

thanks for the review!

@olblak

olblak commented Jun 26, 2026

Copy link
Copy Markdown
Member

thanks for the update, I'll review this pr in the coming days

@olblak olblak added bug Something isn't working core All things related to Updatecli core engine labels Jun 26, 2026
@olblak

olblak commented Jun 26, 2026

Copy link
Copy Markdown
Member

sorry for the confusion on this pullrquest, I now realize that all the comments that I made on this pr where only visible to me because they were "pending"

cfr https://github.com/orgs/community/discussions/10369

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak
haha, no worries. thanks for the review tho :)

@olblak olblak left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I manually tested using the following manifest

name: Test sourceid {{ source "shell" }}

sources:
  shell:
    name: Show 1.2.3
    kind: shell
    dependson:
      - condition#default
    spec:
      command: 'echo "1.2.3"'

  shell2:
    name: Show source output {{ source "shell" }}
    kind: shell
    spec:
      command: 'echo {{ source "shell" }}'

conditions:
  default:
    name: "False"
    kind: shell
    disablesourceinput: true
    spec:
      command: |
        false

And it works as expected.
While testing it, I spotted a minor issue which I'll fix in a follow up pr

@ambikeesshh

Copy link
Copy Markdown
Contributor Author

@olblak
the e2e (Run End to End tests) is red on the latest run, and it's from this change.

turns out a bunch of the repo's own deps: bump manifests hit the new behavior: a source gets skipped via dependson (e.g. actions/checkout when release v4 isn't found → source#branch skipped), but the targets still reference {{ source "branch" }}. on main that rendered as a literal silently, now it errors with "parent source ... was skipped" so ~45 pipelines fail and the e2e assertion trips.

is that covered by the follow-up you mentioned, or would you rather skipped sources also skip their dependents instead of erroring? happy to go either way, just lmk which you prefer

@olblak

olblak commented Jun 26, 2026

Copy link
Copy Markdown
Member

This is not related to my follow up.
Mine is about initializing report data.

I think it would make more sense to not error on skipped source but just to skip dependents resources

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

Labels

bug Something isn't working core All things related to Updatecli core engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A resource using {{ source "sourceid" }} fails if the sourceid is skipped

3 participants