Skip to content

fix(discover): --apply without --yes honors APM_NON_INTERACTIVE and CI - #4413

Merged
Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-discover-non-interactive
Nov 21, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 3 commits into
mainfrom
danielmeppiel-discover-non-interactive

Conversation

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Description

apm init --apply / apm discover --apply without --yes decided whether to prompt from sys.stdin.isatty() alone. On a Windows CI runner stdin is a console. So with APM_NON_INTERACTIVE=1 or CI set, the command still asked "Add the listed dependencies ...? [y/N]", read end-of-file, and exited 1 with "Aborted!" instead of the consent error. Found by the Windows lifecycle journeys (J15 step 4).

  • src/apm_cli/commands/discover.py: the consent gate uses the existing apm_cli.commands.auth.is_interactive(), which returns False when APM_NON_INTERACTIVE or CI is set and otherwise checks stdin. This matches the other prompts (install/phases/integrate.py, security/executables.py).
  • tests/unit/adopt/test_onboarding.py: test_apply_without_consent_never_prompts_when_non_interactive[APM_NON_INTERACTIVE|CI] makes the runner's stdin report a console and asserts the consent error with no [y/N] prompt. Both cases fail without the fix.

Issue and approved scope

Issue: Fixes #4411

Human scope-approval comment: the 0.37 steward ruling relayed by the Stream T lead (Windows journeys: a prompt in CI hangs pipelines; fix in 0.37).

Does this PR complete the issue, or what remains? It completes it.

Type of change

  • Bug fix
  • New feature
  • Documentation
  • Maintenance / refactor

Testing

  • Tested locally
  • All existing tests pass
  • Added tests for new functionality (if applicable)

Results:

  • pytest tests/unit/adopt/test_onboarding.py tests/unit/test_init_command.py: 136 passed.
  • The new cases fail without the change (2 failed).
  • ruff check / format: clean.

Changelog

  • One line in one section under ## [Unreleased] in CHANGELOG.md.
  • N/A -- internal-only change (CI, tests, refactor).

Spec conformance (OpenAPM v0.1)

  • N/A -- this PR does not change OpenAPM-observable behaviour.

@danielmeppiel Daniel Meppiel (danielmeppiel) added this to the 0.37.0 milestone Nov 20, 2026
Copilot AI balanced review requested due to automatic review settings November 20, 2026 16:29
Co-authored-by: copilot-swe-agent[bot] <[email protected]>

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.

🟡 Changes recommended

The CI unit suite fails because the existing interactive-consent tests inherit CI and APM_NON_INTERACTIVE, triggering ClickException before the mocked confirmation; both variables must be cleared in those tests.

1 open issue
What changed in this PR

Fixes #4411 by making discovery’s apply-consent gate honor non-interactive environment settings, including Windows CI consoles.

Changes:

  • Reuses is_interactive() so APM_NON_INTERACTIVE and CI suppress confirmation prompts.
  • Adds parameterized regression coverage for both environment variables.
  • Documents the corrected consent behavior in the changelog.
File Description
tests/​unit/​adopt/​test_onboarding.py Adds console-stdin regression cases for non-interactive consent handling.
src/​apm_cli/​commands/​discover.py Uses the shared interactivity check before prompting.
CHANGELOG.md Records the non-interactive consent fix.

Review effort: Balanced

from apm_cli.commands.auth import is_interactive

# APM_NON_INTERACTIVE and CI forbid a prompt even on a console (#4411).
if not is_interactive() or output_format != "text":
@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit 67bb822 into main Nov 21, 2026
1 check passed
@danielmeppiel
Daniel Meppiel (danielmeppiel) deleted the danielmeppiel-discover-non-interactive branch November 21, 2026 05:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

init --apply prompts in CI on Windows instead of the consent error

2 participants