Skip to content

fix(repos): derive the template answers of an existing repository #7406

Done

Description

@dan-petty

Problem

devops repos onboard <repo> --confirm with no answer flags renders the infra template with default answers, also for a repository that already has a release setup and scopes. render_answers (src/devops_cli/github/onboard/baseline.py:140-155) gives empty scopes, release_flow: true and no release_type, so Copier takes its default simple.

Evidence: the template pull request #7307, made by an onboard run with no flags, has release_type: simple and scopes: ''. devops-cli releases with release-please release-type: python and has 47 scope/* labels. The simple answer also renders version.txt with 0.0.0. After the merge, check_answer_flags (baseline.py:96-116) refuses a flag that differs from .copier-answers.yml, so the wrong answers stay until a person runs copier update --data. #7307 is closed for this reason. dan-petty/vibes#314 came from the same kind of run.

Done when

  • For a repository with no .copier-answers.yml, onboard reads release-type of release-please-config.json and the scope/* labels as the default answers, or refuses the render with a message that names the missing --release-type and --scope flags.
  • A flag still wins over a value that onboard reads.
  • Tests prove both: a repository with release-please-config.json of type python and scope labels, and a new empty repository.

Alternatives check of 2026-11-27: none.
Tool: none found.
Reason: Searches found no tool that infers template answers from a repository's release-please config or scope labels; Copier only renders from answers the caller passes, so onboard must read those facts itself.

Lacks:

  • No reading of release-please-config.json for release-type
  • No discovery of scope labels as answers
  • No derivation of answers from an existing repository

Proposed design

Problem statement

devops repos onboard <repo> --confirm renders the infra template with default answers when a repository already has a release setup and scopes. render_answers gives empty scopes and no release_type, so Copier takes simple and writes version.txt with 0.0.0. The template pull request dan-petty/devops-cli#7307 failed this way. The fix derives the answers from release-please-config.json and the scope/* labels when no .copier-answers.yml exists. A given flag keeps priority.

Acceptance criteria

Requirement: Derive the release type from the repository config

derive_answers SHALL take release_type from the release-type key of the text of release-please-config.json.

Scenario: Config of type python

  • WHEN derive_answers gets the text of a release-please-config.json with "release-type": "python" and an empty label list.
  • THEN It returns {"release_type": "python"}.

Requirement: Derive the scopes from the labels

derive_answers SHALL set scopes from the sorted scope/* labels of the repository.

Scenario: Two scope labels

  • WHEN derive_answers gets no config text and the labels scope/roadmap and scope/cli.
  • THEN It returns {"scopes": "cli,roadmap"}.

Requirement: A flag wins over a derived value

An answer flag MUST override the value that onboard derives from the repository.

Scenario: Flag differs from the config

  • WHEN render_answers gets no answers file, the derived answers {"release_type": "python"} and options with release_type node.
  • THEN The returned answers hold release_type node.

Requirement: A derived value stays when its flag is absent

render_answers MUST keep a derived value when the caller gives no flag for that answer.

Scenario: No scope flag

  • WHEN render_answers gets no answers file, the derived answers {"scopes": "cli,roadmap"} and options with no scope.
  • THEN The returned answers hold scopes cli,roadmap and not "".

Requirement: A new repository keeps the template defaults

derive_answers SHALL return no answer when the repository holds no release setup and no scope label.

Scenario: Empty repository

  • WHEN derive_answers gets no config text and an empty label list.
  • THEN It returns an empty dict, so Copier keeps its own defaults.

Requirement: An unreadable config stops the render

derive_answers MUST raise BaselineUnreadableError with a message that names --release-type when the config text is not valid JSON.

Scenario: Invalid config

  • WHEN derive_answers gets the text { as the config and an empty label list.
  • THEN It raises BaselineUnreadableError and the message names --release-type.

Existing Tool Considered

The alternatives check of 2026-11-27 in the issue body gives the verdict none with no tool: Copier renders only from the answers that its caller passes, so no tool derives the answers of an existing repository. The block lists what a tool would lack. The fix builds the two reads itself in src/devops_cli/github/onboard/baseline.py: about 80 lines of Python and one test module, about 6k tokens and 2 hours of work, with no new dependency to keep or patch.

Key questions

  • When the repository gives no fact for an answer, does onboard refuse the render or keep the template default?: Keep the template default when the repository holds no release setup and no scope label, so a new repository onboards as today. Stop with an error only when a release-please-config.json exists and does not parse, because that repository has a release setup and a silent simple answer is the defect of ci: add the files of the repository template #7307. (best practice) [sources: src/devops_cli/github/onboard/baseline.py:145, src/devops_cli/github/onboard/baseline.py:101, src/devops_cli/github/onboard/run.py:156]
    • Chosen: Derive, keep the default when the repository is empty, refuse an unreadable config. A new repository has no fact to derive, and an unreadable config hides the release setup that caused ci: add the files of the repository template #7307.
    • Rejected: Refuse each render that cannot derive both answers. It stops the onboard of a new repository, which the done-when keeps working.
    • Rejected: Always render the defaults and never refuse. It keeps the silent simple answer for a repository whose config exists but does not parse.
  • In what form does the derived scopes answer go to Copier?: A sorted, comma-joined string, the same form that the --scope flag path builds, because check_answer_flags compares the answer string with the flag value. (best practice) [sources: src/devops_cli/github/onboard/baseline.py:145, src/devops_cli/github/onboard/baseline.py:113]
    • Chosen: Sorted comma-joined string. It matches the existing flag path and the string compare of check_answer_flags.
    • Rejected: YAML list. The flag path and the compare in check_answer_flags hold a string, so a list breaks both.
  • Does the change alter check_answer_flags?: No. check_answer_flags compares a flag with an existing .copier-answers.yml only, and the derivation applies when that file is absent. A repository with wrong answers in the file still needs copier update --data, which is out of this item. (best practice) [sources: src/devops_cli/github/onboard/baseline.py:101, src/devops_cli/github/onboard/baseline.py:113, src/devops_cli/github/onboard/run.py:153]
    • Chosen: Leave the flag check unchanged. The defect is the render with no answers file, and the check already refuses a flag that differs from the file.
    • Rejected: Also rewrite a wrong answers file. It adds a write path and needs the copier update --data step that a person runs.
  • Does render_answers already ignore the derivation when the repository has a .copier-answers.yml?: Yes. It returns the keys of the file and ignores the flags, so the derivation applies only when the file is absent. [sources: src/devops_cli/github/onboard/baseline.py:145, src/devops_cli/github/onboard/run.py:156]
  • Where does onboard read the labels and the config text?: In the caller of render_answers, through the GitHub session of the onboard run. render_answers and derive_answers stay pure, so a test needs no double for a process edge. (best practice) [sources: src/devops_cli/github/onboard/run.py:156, src/devops_cli/github/onboard/baseline.py:145, src/devops_cli/github/onboard/model.py:112]
    • Chosen: Read in the caller and pass the facts to a pure function. A pure function gives a test of the derivation with no GitHub double.
    • Rejected: Read GitHub inside render_answers. It puts a process edge in the render and forces a double in each test.
  • Which key of release-please-config.json holds the release type, and what value does devops-cli use?: The root key release-type, and devops-cli sets python. [sources: release-please-config.json, src/devops_cli/github/onboard/model.py:114]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    type/bug
    source/agent
    status/new
    on Nov 27, 2026
  2. dan-petty commented on Nov 27, 2026

    @dan-petty
    OwnerAuthor
    • Possible duplicate: fix(repos): onboard reads the template answers from the repository #7309, which may ask for the same change. The model names onboard derives release-type and scope answers from the repository's release-please-config.json and scope labels instead of using template defaults as the change that both ask for. Both items ask onboard to read release-type and scopes from the repository's existing facts and use them as defaults when no flags are given. A person closes one of the two if that is so.
  3. added
    value/medium
    effort/medium
    scope/repos
    priority/p2-medium
    on Nov 27, 2026
  4. devops-cli-service commented on Nov 27, 2026

    @devops-cli-service
    Contributor

    The result in the alternatives block of the issue body changed. Before this check: no check. A person decides what the new result means for the item.

    Searches (8)

    Tools considered:

    Searches run:

    • copier template derive answers from existing repository files, results: 5
    • cookiecutter infer template variables from existing project files, results: 5
    • release-please-config.json release-type read programmatically python, results: 5
    • copier-org copier answers file --data defaults documentation, results: 5
    • copier update --data answers migration, results: 5
    • copier answers yaml copier update data defaults, results: 5
    • copier python project template, results: 5
    • tool infer project template variables from repository labels and release config, results: 5

    Sources:

  5. added
    status/ready
    and removed
    status/new
    on Nov 28, 2026
  6. devops-cli-service commented on Nov 28, 2026

    @devops-cli-service
    Contributor

    Next step: the stage job writes the plan of the item. See the section Proposed design of the body.

  7. added
    owner/agent
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 28, 2026
  8. removed
    status/in-review
    owner/agent
    on Nov 28, 2026
  9. devops-cli-service commented on Nov 29, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-29 00:41 UTC

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    effort/mediumpriority/p2-mediumscope/repossource/agenttype/bugvalue/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions