Skip to content

Derived defaults are not updated when referenced property is updated #2719

Description

@lhupfeldt

Describe the problem

Given the following template config:

_subdirectory: template

a:
  type: str
  default: "a1"

b:
  type: str
  default: "b {{ a }}"

template/{{_copier_conf.answers_file}}.jinja

copier copy <emplate> <dest>
No git tags found in template; using HEAD as ref
🎤 a
   a1
🎤 b
   b a1
cd <dest>
 
copier update --vcs-ref HEAD --data a=a2
Keeping template version 0.0.0.post1.dev0+580c8b4
🎤 b
   b a1

The default for b, if not otherwise changed from the previous default, should be b a2.
The same issue exists if the default for a was changed in a new template version.

This is even more error prone if using --skip-answered

Fixing this may require more meta data in the answers file, so maybe a candidate for the ongoing re-factoring?

Template

copier.yaml:


_subdirectory: template

a:
  type: str
  default: "a1"

b:
  type: str
  default: "b {{ a }}"

and template/{{_copier_conf.answers_file}}.jinja

ps. For some reason I'm unable to upload files.

To Reproduce

No response

Logs

Expected behavior

Derived default property values are updated when property values which they are derived from are updated.

Screenshots/screencasts/logs

No response

Operating system

Linux

Operating system distribution and version

Fedora 44

Copier version

9.15.1

Python version

3.14.4

Installation method

pip+pypi

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugtriageTrying to make sure if this is valid or not

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions