Skip to content

fix: match TLS failure hint to the selected trust mode - #2602

Merged
Daniel Meppiel (danielmeppiel) merged 7 commits into
microsoft:mainfrom
aryansk:fix/2035-doctor-tls-diagnostic
Nov 12, 2026
Merged

Daniel Meppiel (danielmeppiel) merged 7 commits into
microsoft:mainfrom
aryansk:fix/2035-doctor-tls-diagnostic

Conversation

@aryansk

@aryansk Aryan Singh K. (aryansk) commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Closes #2035

Summary

  • report the active TLS trust source and precedence in apm doctor
  • isolate process-global SSL/truststore state between tests with a shared autouse fixture
  • add regression coverage for the doctor TLS row

Validation

  • patch syntax and application context were checked against current main
  • repository tests could not be executed in this chat environment; CI should run the project test suite

Maintainer-side folds (2026-11-12, per the #2035 apm-scope:v1 record)

The approved scope on #2035 accepts only the correction to core-HTTPS TLS failure guidance. It lists new doctor TLS output and shared SSL-fixture consolidation as out of scope, so this branch was reworked on top of Aryan Singh K. (@aryansk)'s commit (authorship preserved with Co-authored-by trailers):

  • 21c7fa9: reverts the apm doctor TLS row, describe_tls_trust, and the doctor test to main. The shared autouse SSL fixture was dropped in the main merge.
  • c9ae9a1: configure_tls_trust (the canonical TLS owner) records a structured TLSTrustSelection on every path. tls_failure_guidance() maps it to truthful advice, and install/validation.py renders that advice instead of a hard-coded string. With APM_DISABLE_TRUSTSTORE or a REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE replacement active, the hint names that setting and a safe next step. It no longer recommends the OS store or APM_EXTRA_CA_BUNDLE, which those modes ignore. Default output is byte-identical. Trust selection, precedence, and verification are unchanged.
  • 8e4d033: folds the panel's doc follow-ups (troubleshooting pages, apm-usage guidance) and clarifies the replacement-plus-opt-out wording.

Validation: owner-level regressions for every scope case, plus the real apm install CLI path in normal and --verbose modes with a controlled SSLError (exit 1 preserved). The mutation-break gate passed: the new tests fail when the guard is removed. The CI lint mirror is clean.

Closes #2035

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

Note

Copilot was unable to run its full agentic suite in this review.

Adds a new “TLS trust” informational check to apm marketplace doctor and stabilizes test isolation around process-global truststore injection.

Changes:

  • Introduced describe_tls_trust() to generate user-facing TLS trust-source and precedence text.
  • Added a new “TLS trust” informational doctor check and a corresponding unit test assertion.
  • Added an autouse pytest fixture to reset truststore/SSL-related global state between tests.

Reviewed changes

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

File Description
tests/unit/commands/test_marketplace_doctor.py Adds a unit test ensuring the doctor output includes the TLS trust section/source.
tests/conftest.py Adds an autouse fixture to reset truststore injection and clear TLS trust configuration cache between tests.
src/apm_cli/core/tls_trust.py Adds describe_tls_trust() to report TLS trust source and precedence.
src/apm_cli/commands/marketplace/doctor.py Adds a new informational “TLS trust” check to doctor output.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/apm_cli/core/tls_trust.py Resolved
Comment thread src/apm_cli/core/tls_trust.py Resolved
Comment thread src/apm_cli/core/tls_trust.py Resolved

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

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

Suppressed comments (5)

src/apm_cli/commands/marketplace/doctor.py:198

  • This introduces a second "Check 4" header; it makes the check numbering confusing when scanning the function. Consider removing the numeric label here (or renumbering all subsequent checks).
    # Check 4: TLS trust source (informational)

src/apm_cli/commands/marketplace/doctor.py:205

  • TLS trust diagnostic detail can include non-ASCII text (explicit CA bundle paths, truststore error messages). That can trigger UnicodeEncodeError on Windows terminals and violates the repo's printable-ASCII output constraint. Sanitize the rendered strings before adding them to the doctor table (including the exception path).
    try:
        from ...core.tls_trust import describe_tls_trust

        tls_source, tls_precedence = describe_tls_trust()
        tls_detail = f"{tls_source}; precedence: {tls_precedence}"

tests/conftest.py:149

  • The new autouse SSL isolation fixture calls truststore.extract_from_ssl(), but it does not snapshot/restore ssl.SSLContext itself. Some tests (e.g. TLS integration suites) directly assign ssl.SSLContext, and without restoring it here a future test could leak a patched SSLContext into subsequent tests.
@pytest.fixture(autouse=True)
def _isolate_ssl_state():
    """Restore process-global truststore injection between tests."""
    import contextlib

src/apm_cli/core/tls_trust.py:115

  • describe_tls_trust() is documented as "user-facing", but it can embed non-ASCII bytes from REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE values or from exception messages recorded in _LAST_TLS_STATUS. If callers print this directly (as apm doctor does), it can violate the repo's printable-ASCII output constraint on Windows.
def describe_tls_trust(env: Mapping[str, str] | None = None) -> tuple[str, str]:
    """Return a user-facing trust source and precedence description."""
    if _env_flag(_DISABLE_ENV_VAR, env):
        source = f"bundled CA (certifi); {_DISABLE_ENV_VAR}=1 disables OS trust-store injection"
    elif has_explicit_ca_override(env):

tests/conftest.py:129

  • The linked issue acceptance criteria calls out removing the per-suite SSL/truststore isolation guards once a shared autouse fixture exists, but those guards still remain (e.g. tests/integration/test_tls_custom_ca.py:_isolate_trust and tests/integration/test_tls_frozen_hook.py:_isolate_trust). This PR adds the shared fixture but does not remove the redundant per-suite ones.
@pytest.fixture(autouse=True)
def _isolate_ssl_state():
    """Restore process-global truststore injection between tests."""

@sergio-sisternes-epam

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_with_followups

apm doctor now surfaces the active TLS trust source, unblocking corporate-proxy users who silently fail on custom CA bundles.

cc Aryan Singh K. (@aryansk) Daniel Meppiel (@danielmeppiel) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Panel consensus is clear: the PR lands a well-placed, non-blocking diagnostic that addresses the #1 silent failure mode for enterprise CLI adoption (corporate proxy / custom CA). Architecture is sound -- describe_tls_trust lives in the canonical TLS module, the doctor check is informational-only, and no security surfaces are breached. All six active panelists converged on 'ship with polish'.

The two highest-signal follow-ups are (1) missing unit tests for describe_tls_trust's 4 branches and the error-degradation path -- these are regression traps on a user-promise surface and rank above opinion findings per test-evidence weighting -- and (2) the verbose precedence string that three panelists independently flagged as too dense for an 80-col table cell. The stale-read concern (python-architect, supply-chain) is real but low-impact: doctor is a short-lived CLI invocation where configure_process_tls_trust fires early in the command chain; documenting or eagerly calling it is a safe follow-up, not a blocker.

No panelist raised a blocking-severity finding. The CHANGELOG and docs gaps (doc-writer) are standard hygiene that should land in the same PR or an immediate follow-up before the next release cut.

Dissent. Python-architect and supply-chain-security both flagged stale _LAST_TLS_STATUS but diverged on remedy: architect wants an eager call, security wants documentation or querying ssl.SSLContext at call time. I side with the architect's eager-call approach -- it is one cached function call, zero-cost, and eliminates the confusing 'not selected yet' message that devx-ux independently flagged as user-hostile. The security suggestion to query SSLContext directly is over-engineered for an informational diagnostic.

Aligned with: Pragmatic as npm: Mirrors pip config debug and brew doctor patterns -- show users what is active, not a wall of internals. Progressive disclosure (--verbose for precedence chain) keeps the default output scannable. | Secure by default: Diagnostic is read-only, never mutates trust state. Supply-chain expert confirmed no credential leakage or security bypass. Path disclosure in CI logs is low-risk given the tool's local-execution model.

Growth signal. Corporate proxy/custom-CA is the #1 reason CLI tools silently fail at large orgs. This PR converts a 'file a ticket' moment into a self-service diagnostic -- worth a beat in release notes targeting enterprise adopters. Frame CHANGELOG as: 'apm doctor now tells you why TLS fails in corporate networks.' Compounds with any future apm doctor --fix auto-remediation.

Panel summary

Persona B R N Takeaway
Python Architect 0 1 1 Solid placement of describe_tls_trust in the canonical TLS module. The module-global _LAST_TLS_STATUS read is acceptable for an informational diagnostic but has a stale-read edge case worth documenting. No blocking issues.
CLI Logging Expert 0 1 2 The TLS doctor check is well-structured but the precedence chain is too verbose for a table cell -- it belongs behind --verbose. The rest is clean.
DevX UX Expert 0 2 2 The TLS trust row is a good diagnostic addition but the inline precedence string is too dense for a table cell, the 'not selected yet' message is confusing, and the error fallback lacks actionable guidance.
Supply Chain Security Expert 0 2 2 No security bypasses or credential leakage. Minor concerns around path disclosure and misleading pass status, but nothing blocking.
OSS Growth Hacker 0 0 2 Strong adoption move. TLS diagnostics in apm doctor is exactly the kind of self-service debugging that unblocks enterprise users behind corporate proxies -- the #1 silent churn vector for CLI tools in regulated environments.
Doc Writer 0 2 1 The PR adds a new TLS trust row to apm doctor output. The CHANGELOG [Unreleased] section has no entry. The docs reference page Checks table does not list TLS trust. Two targeted updates needed.
Test Coverage Expert 0 2 1 New describe_tls_trust() has zero direct tests covering its 4 branches; doctor error path untested; autouse fixture leaks _LAST_TLS_STATUS across tests.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 5 follow-ups

  1. [Test Coverage Expert] Add parametrized unit tests for describe_tls_trust's 4 branches -- Missing regression trap on a user-promise surface (devx principle). No automated guardrail currently proves the precedence logic is correct.
  2. [Test Coverage Expert] Add test for doctor TLS error-degradation path -- The except block that renders 'Unable to determine' has zero coverage -- if it regresses, doctor crashes instead of degrading gracefully.
  3. [CLI Logging Expert] Move precedence chain behind --verbose; show only active source in default table -- Three panelists independently flagged the 120+ char detail string as too dense for 80-col terminals. Progressive disclosure is APM's output contract.
  4. [Python Architect] Eagerly call configure_process_tls_trust() inside describe_tls_trust to eliminate stale-read / 'not selected yet' UX -- Eliminates confusing cold-state message and satisfies devx-ux's reword request in one line.
  5. [Doc Writer] Add CHANGELOG entry and update doctor.md Checks table with TLS trust row -- User-visible behavior change with no changelog or docs update -- violates 'ship fast, communicate clearly' principle.

Architecture

classDiagram
    direction LR
    class tls_trust {
        <<Module>>
        +configure_process_tls_trust() None
        +describe_tls_trust(env) tuple
        +has_explicit_ca_override(env) bool
        -_LAST_TLS_STATUS tuple|None
        -_env_flag(name, env) bool
        -_explicit_ca_path(env) str
    }
    class doctor {
        <<Module>>
        +run_doctor() list~DoctorCheck~
    }
    class _DoctorCheck {
        <<Dataclass>>
        +name str
        +passed bool
        +detail str
        +informational bool
    }
    doctor ..> tls_trust : imports describe_tls_trust
    doctor *-- _DoctorCheck : builds
    class tls_trust:::touched
    class doctor:::touched
    classDef touched fill:#fff3b0,stroke:#d47600
Loading
flowchart TD
    A["apm doctor command"] --> B{"configure_process_tls_trust\ncalled earlier?"}
    B -->|Yes| C["_LAST_TLS_STATUS populated"]
    B -->|No| D["_LAST_TLS_STATUS is None"]
    C --> E["describe_tls_trust()\nreads _LAST_TLS_STATUS"]
    D --> F["describe_tls_trust()\nreturns fallback string"]
    E --> G["Renders TLS source + precedence"]
    F --> G
    G --> H["_DoctorCheck\ninformational=True"]
    H --> I["Print doctor table"]
Loading

Recommendation

Ship now with the understanding that the test-coverage and --verbose follow-ups land before the next release cut. The core diagnostic is correct, non-blocking, and immediately valuable to the enterprise adoption surface. The missing tests are not blocking because the feature is informational-only (passed=True, informational=True) -- a regression here cannot break installs or corrupt state. Recommend the author addresses the top 3 follow-ups in a stacked PR or amends this one before merge.


Full per-persona findings

Python Architect

  • [recommended] Stale-read of _LAST_TLS_STATUS produces misleading 'not selected yet' message if doctor runs before configure_process_tls_trust fires at src/apm_cli/core/tls_trust.py
    If apm doctor runs in a fresh process where configure_process_tls_trust() has not been called, _LAST_TLS_STATUS is None and the user sees 'not selected yet; OS trust store preferred with certifi fallback'. The actual trust source has not been determined yet. describe_tls_trust should eagerly call configure_process_tls_trust() (cached, so idempotent) to ensure the global is populated before reading it.
    Suggested: At the top of describe_tls_trust, call configure_process_tls_trust() to ensure _LAST_TLS_STATUS is populated.
  • [nit] Stale Check 4 comment numbering after insertion -- two checks labeled Check 4 at src/apm_cli/commands/marketplace/doctor.py
    Purely cosmetic but makes grep-by-number unreliable.

CLI Logging Expert

  • [recommended] Precedence chain concatenated into detail string is too verbose for default table output -- wraps badly at 80-col terminals at src/apm_cli/commands/marketplace/doctor.py
    The combined tls_detail string can exceed 120 chars (source + '; precedence: APM_DISABLE_TRUSTSTORE > REQUESTS_CA_BUNDLE/CURL_CA_BUNDLE > APM_EXTRA_CA_BUNDLE (when supported) > OS trust store > certifi fallback'). In a table cell at 80-col terminal this wraps badly and buries the actionable source info. Show only tls_source in default mode; emit the full precedence chain only under --verbose. This follows APM's progressive-disclosure contract.
  • [nit] Precedence string uses '(when supported)' hedging language -- specify or drop at src/apm_cli/core/tls_trust.py
    Either state the condition precisely or omit the qualifier for cleaner output.
  • [nit] Error fallback truncation at 60 chars arbitrary -- may cut mid-word at src/apm_cli/commands/marketplace/doctor.py
    The [:60] slice could cut mid-word or mid-path. Consider truncating to last space or using a utility that appends '...' when truncated.

DevX UX Expert

  • [recommended] Inline precedence chain is reference documentation, not diagnostic output -- belongs behind --verbose at src/apm_cli/commands/marketplace/doctor.py
    Show only the active source in the default view; move the precedence explanation behind --verbose or a apm doctor --explain flag. Compare: pip config debug prints the active config file, not the full resolution order inline.
  • [recommended] 'not selected yet' message reads as broken state to users who haven't run network commands at src/apm_cli/core/tls_trust.py
    Reword to 'OS trust store (default)' or similar positive statement -- the user doesn't need to know about lazy initialization.
  • [nit] Error fallback lacks actionable guidance for next steps at src/apm_cli/commands/marketplace/doctor.py
    Append a hint: 'run with --verbose or check REQUESTS_CA_BUNDLE'. Every doctor error should be one copy-paste away from recovery.
  • [nit] Consider surfacing REQUESTS_CA_BUNDLE hint for corporate-proxy users when no custom bundle detected at src/apm_cli/core/tls_trust.py
    Surface 'set REQUESTS_CA_BUNDLE to your corporate CA path' when no custom bundle detected and OS trust store in use -- the primary audience for this check.

Supply Chain Security Expert

  • [recommended] str(exc)[:60] in error fallback may leak filesystem paths from unexpected exceptions at src/apm_cli/commands/marketplace/doctor.py
    Consider sanitizing to just the exception type name when the message contains path separators or known sensitive patterns.
    Suggested: Use type(exc).name as the safe fallback, or filter the message through a path-redaction helper before truncating.
  • [recommended] _LAST_TLS_STATUS is module-global mutable state read without synchronization -- may be stale at src/apm_cli/core/tls_trust.py
    In long-lived processes or concurrent test runs it could reflect a stale or different trust configuration than what is currently active, making the doctor output misleading rather than informative. Document that this is a snapshot.
    Suggested: Document clearly that this is a snapshot, or query ssl.SSLContext default_verify_paths() at call time.
  • [nit] CA bundle path exposed in diagnostic output -- low-risk but reveals filesystem layout in CI logs at src/apm_cli/core/tls_trust.py
    Exposing the full CA bundle path via _explicit_ca_path(env) is low-risk (diagnostic tool user runs locally) but in CI logs it reveals internal filesystem layout.
  • [nit] passed=True unconditionally may green-light a potentially insecure config (certifi fallback in corp env) at src/apm_cli/commands/marketplace/doctor.py
    Consider making it informational=True with passed=None or a tri-state so it does not green-light a potentially insecure config.

OSS Growth Hacker

  • [nit] Consider linking to a docs troubleshooting anchor in the CHANGELOG entry so the surface compounds at src/apm_cli/commands/marketplace/doctor.py
    The detail string showing env-var precedence is excellent -- users paste this into Slack. Link to docs anchor to make it compound.
  • [nit] CHANGELOG opportunity: frame as 'apm doctor now tells you why TLS fails in corporate networks'
    That framing is a repostable one-liner for enterprise DevRel channels and HN threads about proxy pain.

Auth Expert -- inactive

PR only adds a read-only TLS diagnostic reporter; no auth.py, token_manager.py, AuthResolver, or HTTP auth surfaces touched.

Doc Writer

  • [recommended] Missing CHANGELOG entry for new TLS trust row in apm doctor at CHANGELOG.md
    The [Unreleased] section has no entry for this behavior change. The PR closes Add apm doctor tls trust-source diagnostic + test-suite ssl-isolation fixture #2035 and adds a new informational TLS trust row -- this is user-visible and belongs in the changelog.
    Suggested: Add under ### Fixed: apm doctor now reports the active TLS trust source as an informational row. (closes Add apm doctor tls trust-source diagnostic + test-suite ssl-isolation fixture #2035)
  • [recommended] docs/src/content/docs/reference/cli/doctor.md Checks table missing TLS trust row at docs/src/content/docs/reference/cli/doctor.md
    The reference page lists every apm doctor check row but omits TLS trust. Users running apm doctor will see the row and find no explanation in the docs.
  • [nit] packages/apm-guide commands.md does not mention TLS trust in apm doctor description at packages/apm-guide/.apm/skills/apm-usage/commands.md
    Secondary agent-usage reference omits the new check. Lower priority.

Test Coverage Expert

  • [recommended] No unit tests for describe_tls_trust() branch logic -- 4 branches uncovered at src/apm_cli/core/tls_trust.py
    describe_tls_trust has 4 distinct branches (disable env, explicit CA, cached status, cold state). grep of tests/ shows only one hit: a mock in the doctor test that never exercises the real function. No tests in tests/unit/core/test_tls_trust.py cover it.
    Suggested: Add parametrized unit tests in tests/unit/core/test_tls_trust.py exercising each branch.
    Proof (missing): tests/unit/core/test_tls_trust.py::test_describe_tls_trust_branches -- proves: describe_tls_trust returns correct source string for each precedence branch [devx]
    assert source == 'bundled CA (certifi); APM_DISABLE_TRUSTSTORE=1 disables OS trust-store injection'
  • [recommended] Doctor TLS error path (except Exception block) has no test at tests/unit/commands/test_marketplace_doctor.py
    The only doctor TLS test patches describe_tls_trust to return a tuple (happy path). No test verifies the error rendering or that the check degrades gracefully.
    Suggested: Add a test that patches describe_tls_trust to raise RuntimeError and asserts exit_code == 0 and 'Unable to determine' in output.
    Proof (missing): tests/unit/commands/test_marketplace_doctor.py::test_tls_trust_error_degrades_gracefully -- proves: doctor does not crash when TLS introspection fails; user sees informational degradation [devx]
    assert 'Unable to determine TLS trust source' in result.output
  • [nit] Autouse fixture _isolate_ssl_state does not reset _LAST_TLS_STATUS global -- state leaks between tests at tests/conftest.py
    The fixture clears the lru_cache and calls truststore.extract_from_ssl() but never resets the module-level _LAST_TLS_STATUS. A test calling configure_tls_trust pollutes describe_tls_trust's third branch for all subsequent tests.
    Suggested: Add import apm_cli.core.tls_trust as _tls; _tls._LAST_TLS_STATUS = None in the fixture teardown.

Performance Expert -- inactive

PR adds a diagnostic-only describe_tls_trust() function with no loops, no I/O, no subprocess calls; no hot-path (install/resolve/cache/transport) surfaces touched.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) removed the panel-review Request an advisory PR review; consumed after review. Not human approval or a merge gate. label Aug 18, 2026
@sergio-sisternes-epam

Sergio Sisternes (sergio-sisternes-epam) commented Sep 17, 2026 •

Copy link
Copy Markdown
Collaborator

Thank you for contributing this pull request. APM starts with an
issue, not an implementation
(https://github.com/microsoft/apm/blob/main/CONTRIBUTING.md).

This PR closes #2035, which is a real linked issue, but it is not
currently labelled status/accepted. Maintainer acceptance on that
issue was withdrawn on 2026-09-12; previous acceptance comments are
not approval to continue implementation.

Please keep the user problem on an issue so a maintainer can review
and accept the bounded scope first. This PR is labelled
status/deferred until that happens. Existing CODEOWNERS review
requests are unchanged.


Generated by autopilot-pr-triage-worker. This comment is AI-generated and may contain errors.

@sergio-sisternes-epam Sergio Sisternes (sergio-sisternes-epam) added triage/recommended Automated advice completed; not human scope approval. status/deferred Not invited for implementation now; no release commitment. theme/security area/cli CLI command surface, flags, help text (cross-cutting). area/testing Test infrastructure, fixtures, e2e harness, coverage. type/feature New capability, new flag, new primitive. labels Sep 17, 2026
Conflict in tests/conftest.py resolved to main: the shared autouse
SSL-isolation fixture is outside the microsoft#2035 apm-scope:v1 record
("no broad fixture refactor is needed for this correction").

Co-authored-by: Copilot App <[email protected]>
The microsoft#2035 apm-scope:v1 record (Decision: approve, 2026-10-21) accepts
only the correction to core-HTTPS TLS failure guidance and lists
"New doctor TLS output or subcommands" and broad SSL fixture work as
out of scope. describe_tls_trust also duplicated trust precedence
(placing APM_DISABLE_TRUSTSTORE above an explicit replacement bundle,
which contradicts configure_tls_trust), which the record forbids.
Restore doctor.py, tls_trust.py and the doctor tests to main so the
in-scope correction can be built on the canonical TLS owner.

Addresses Copilot inline on src/apm_cli/core/tls_trust.py:103.

Co-authored-by: aryansk <[email protected]>
Co-authored-by: Copilot App <[email protected]>
…t#2035)

The normal TLS failure hint was unconditional: it recommended the OS
trust store and APM_EXTRA_CA_BUNDLE even when APM_DISABLE_TRUSTSTORE
or a REQUESTS_CA_BUNDLE / CURL_CA_BUNDLE replacement made both
ineffective. This is the defect accepted by the microsoft#2035 apm-scope:v1
record.

configure_tls_trust, the canonical TLS owner, now records a structured
TLSTrustSelection on every path alongside its existing debug line, and
tls_failure_guidance() maps that selection to truthful next-step
guidance. install/validation.py renders the owner's guidance instead of
a hard-coded string, so precedence is not duplicated and diagnostic
strings are never parsed as authority. Default/OS-store output is
byte-identical; additive, certifi-fallback and unrecorded states stay
truthful without naming a setting. No trust selection, precedence,
verification or verbose diagnostics change.

Regressions cover opt-out, requests/curl replacement, replacement plus
opt-out, ignored additive input and the kept modes at the owner, plus
the real `apm install` CLI path in normal and --verbose modes with a
controlled SSLError (failed exit preserved). Tests that assert the
default wording now pin the unrecorded selection so they stay
order-independent. Troubleshooting docs, apm-usage guidance and the
CHANGELOG are updated.

Co-authored-by: aryansk <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_with_followups

TLS failure hints now route through the canonical trust owner instead of a hard-coded string -- community contribution, all six panelists converge on ship with two doc fixes to fold.

panel-mode=full; personas=python-architect,test-coverage-expert,auth-expert,doc-writer,devx-ux-expert,supply-chain-security-expert,apm-ceo

cc Aryan Singh K. (@aryansk) Daniel Meppiel (@danielmeppiel) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

The apm-scope:v1 record on #2035 asked for one thing: make the SSL-failure hint consistent with the trust mode actually selected by the existing canonical TLS owner. The PR delivers exactly that. configure_tls_trust now records a frozen TLSTrustSelection on every return path, and _log_tls_failure in validation.py calls the owner for guidance instead of emitting a hard-coded string. The python-architect confirms single-owner authority is preserved with no split precedence; the supply-chain-security-expert confirms guidance never steers toward weakening verification; the auth-expert confirms no credential or token surface is touched. The test-coverage-expert reports all 12 scope-case regressions land with mutation evidence (26 failures on bypass), confirming every trap is load-bearing. Zero blocking findings across all six panelists.

The doc-writer raises two recommended findings worth folding before merge: (1) ssl-issues.md tells users with an intentional setting to 'keep it' but gives no next action that would actually fix the failure -- the owner provides that action (ensure the replacement bundle has the needed CAs; with opt-out alone, set REQUESTS_CA_BUNDLE to a complete bundle), so the doc should too; (2) common-errors.md repeats the ssl-issues paragraph redundantly when a one-sentence cross-reference suffices. Both are in scope ('update directly affected troubleshooting and usage guidance') and both are surgical one-line edits. The devx-ux-expert's nit on the replacement+opt-out fallback clause ('without that replacement' reads ambiguously under stress) is confirmed by a passing test (test_replacement_with_opt_out_names_both_settings in tests/unit/core/test_tls_trust.py) -- the user promise holds on this commit, and the polish is optional. The doc-writer's third finding (symptom-block drift in ssl-issues.md) predates this PR; worth a follow-up but not required.

This is a community contribution (Aryan Singh K. (@aryansk)) that went through a full governance cycle: original overshoot, maintainer scope record, revert of out-of-scope changes, and precise in-scope implementation. The CHANGELOG 'Fixed' entry tells the right story: TLS failure hints now match the trust mode actually in effect. No breaking changes, no new public API surface for consumers, no migration needed. All four earlier Copilot inline signals (describe_tls_trust precedence, duplicate Check 4, exc truncation, missing unit tests) are resolved -- the offending code was reverted as out of scope, and owner-level regressions replace the originally requested unit tests.

Aligned with: Secure by default: Guidance is truthful per trust mode and never suggests disabling verification or weakening the trust boundary.; Pragmatic as npm: Mode-specific actionable hints replace a generic certificate wall; users get a concrete next step.; OSS community driven: Community contributor Aryan Singh K. (@aryansk) with maintainer-scoped folds preserving contributor authorship on the branch.

Growth signal. This PR demonstrates the contributor governance loop end-to-end: community PR, scope overshoot caught, bounded scope record issued, contributor-branch folds, and a clean re-delivery. Worth highlighting in release notes as evidence that external contributors can land security-adjacent changes through the accepted-scope process.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 1 Clean single-owner extension: frozen TLSTrustSelection records configure_tls_trust decisions; consumer routes through tls_failure_guidance(). No split authority, no scope creep.
DevX UX Expert 0 0 1 Guidance strings are actionable and mode-truthful; no ignored remedies leak; one phrasing nit on the rare replacement+opt-out combined clause.
Supply Chain Security Expert 0 0 0 TLS verification semantics, trust-selection boundaries, and secret/path containment are preserved; guidance never steers toward weakening verification.
Auth Expert 0 0 0 Auth-neutral: no AuthResolver, token, or credential-flow changes; guidance text names env var names only, never values; TLS-classification path untouched.
Doc Writer 0 2 1 Docs are accurate on the main point and the CHANGELOG format is correct. Fix the ssl-issues next step for intentional settings and remove the repeated common-errors paragraph.
Test Coverage Expert 0 0 0 All 12 scope-case regressions land with unit + CliRunner coverage and correct module-global isolation; mutation evidence (26 failures on bypass) confirms traps are load-bearing; ship.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Top 4 follow-ups

  1. [Doc Writer] ssl-issues.md: add the owner's safe next action for intentional replacement and opt-out settings instead of 'keep the setting if it is intentional' -- In scope ('update directly affected troubleshooting and usage guidance'). The record requires a safe next action; the current sentence stops short.
  2. [Doc Writer] common-errors.md: collapse the repeated TLS paragraph to a one-sentence cross-reference to ssl-issues.md -- In scope. Redundant guidance that also mishandles the opt-out-only case.
  3. [DevX UX Expert] Rephrase the replacement+opt-out fallback clause from 'without that replacement' to an explicit if-you-unset warning -- In scope, low priority polish on the rarest path; the user promise already holds.
  4. [Doc Writer] Update the ssl-issues.md Symptoms sample block to match the actual default guidance text -- Pre-existing drift, but the new paragraph now points readers at that block.

Architecture

classDiagram
    direction LR
    class TLSTrustSource {
        <<Enum>>
        REPLACEMENT
        OPT_OUT
        OS_STORE
        OS_STORE_ADDITIVE
        CERTIFI_FALLBACK
        CERTIFI_ADDITIVE
    }
    class TLSTrustSelection {
        <<ValueObject>>
        +source TLSTrustSource
        +replacement_setting str
        +opt_out bool
    }
    class tls_trust {
        <<CanonicalOwner>>
        +configure_tls_trust(env) bool
        +tls_failure_guidance() str
        +selected_tls_trust() TLSTrustSelection
        +explicit_ca_bundle_path(env) str
        -_record_tls_trust_status(sel, msg)
        -_tls_failure_guidance_for(sel) str
        -_explicit_ca_selection(env) tuple
        -_LAST_TLS_SELECTION TLSTrustSelection
    }
    class validation {
        <<Consumer>>
        -_log_tls_failure(host, exc, verbose, logger)
    }
    TLSTrustSelection *-- TLSTrustSource : source
    tls_trust ..> TLSTrustSelection : records and reads
    validation ..> tls_trust : tls_failure_guidance()
    class TLSTrustSource:::touched
    class TLSTrustSelection:::touched
    class tls_trust:::touched
    class validation:::touched
    classDef touched fill:#fff3b0,stroke:#d47600
Loading
flowchart TD
    A["apm install owner/repo"] --> B["configure_tls_trust<br/>core/tls_trust.py"]
    B --> C{explicit replacement set?}
    C -->|yes| E["record REPLACEMENT<br/>winning var + opt_out flag"]
    C -->|no| F{APM_DISABLE_TRUSTSTORE?}
    F -->|yes| G["record OPT_OUT"]
    F -->|no| H{truststore injected?}
    H -->|yes| I["record OS_STORE or OS_STORE_ADDITIVE"]
    H -->|no| J["record CERTIFI_FALLBACK or CERTIFI_ADDITIVE"]
    E --> K["_LAST_TLS_SELECTION"]
    G --> K
    I --> K
    J --> K
    K --> L["install/validation.py probe"]
    L --> M{SSLError?}
    M -->|yes| N["_log_tls_failure"]
    N --> O["tls_failure_guidance()"]
    O --> Q["logger.warning: mode-specific hint"]
    M -->|no| R["validation continues"]
Loading

Recommendation

Fold the two doc-writer recommended findings (ssl-issues.md safe next action and common-errors.md redundancy collapse) -- both are in scope and one-line edits -- then ship. The devx phrasing nit is optional polish; the symptom-block drift can follow. Core code is clean, well-tested (423 targeted, 26 mutation-break failures), architecturally sound, and security-neutral.


Full per-persona findings

Python Architect

  • [nit] Design patterns applied correctly; no additions warranted at this scope.
    Used: frozen dataclass value object (TLSTrustSelection) carrying the trust decision from configure_tls_trust to the guidance renderer; Enum vocabulary (TLSTrustSource) for the six trust modes; record-then-read module state extending the pre-existing _LAST_TLS_STATUS pattern (mutated at startup only); extract-and-delegate (_explicit_ca_selection, which explicit_ca_bundle_path now delegates to, so replacement precedence is not duplicated). The if-chain in _tls_failure_guidance_for is the simplest correct shape for six branches with one conditional clause.

DevX UX Expert

  • [nit] REPLACEMENT+OPT_OUT fallback clause: 'without that replacement' is ambiguous under stress at src/apm_cli/core/tls_trust.py:172
    In the combined REPLACEMENT+OPT_OUT path, the fallback sentence reads 'APM_DISABLE_TRUSTSTORE is also set, so without that replacement APM verifies against its bundled CA set only.' A stressed user may parse 'without that replacement' as a concurrent state description rather than a what-happens-if-you-unset warning. The sentence's purpose is to warn that unsetting the replacement does not restore OS trust. Rarest of the six paths, small blast radius.
    Suggested: Replace the fallback template with: f" If you unset {setting}, {_DISABLE_ENV_VAR} still prevents OS trust-store use and APM falls back to its bundled CA set only."
    Proof (passed): tests/unit/core/test_tls_trust.py::test_replacement_with_opt_out_names_both_settings -- proves: Combined replacement+opt-out guidance names both settings and warns about bundled-CA-only fallback

Supply Chain Security Expert

No findings.

Auth Expert

No findings.

Doc Writer

  • [recommended] ssl-issues.md tells users to keep an intentional setting, but gives no action that would fix the failure at docs/src/content/docs/troubleshooting/ssl-issues.md:23
    The new paragraph ends with 'Keep the setting if it is intentional; otherwise unset it and retry.' The owner guidance gives a real next step for intentional settings (make sure the replacement bundle contains every CA you need; with opt-out alone, set REQUESTS_CA_BUNDLE to a complete PEM bundle). A user following the doc changes nothing and gets the same failure. The record asks for a safe next action per mode.
    Suggested: Replace the last sentence with: 'If the setting is unintended, unset it and retry. If it is intended, make sure the replacement bundle contains every CA you need; with APM_DISABLE_TRUSTSTORE alone, set REQUESTS_CA_BUNDLE to a complete PEM bundle.'
  • [recommended] common-errors.md repeats the ssl-issues paragraph, and its wording does not fit the opt-out-only case at docs/src/content/docs/troubleshooting/common-errors.md:280
    The common-errors entry already ends with 'See also: SSL issues', so restating the guidance breaks the state-once, reference-elsewhere rule. It also says 'make sure a replacement bundle contains every CA you need', but with APM_DISABLE_TRUSTSTORE alone no replacement exists; the owner's advice is to set REQUESTS_CA_BUNDLE.
    Suggested: Cut the paragraph to one sentence that points to the canonical page: 'If the hint names APM_DISABLE_TRUSTSTORE, REQUESTS_CA_BUNDLE, or CURL_CA_BUNDLE, follow its advice; see SSL issues for each trust mode.'
  • [nit] The ssl-issues symptom block that the new paragraph calls 'the first hint' does not match the real default text at docs/src/content/docs/troubleshooting/ssl-issues.md:15
    The sample under Symptoms ends with 'set APM_EXTRA_CA_BUNDLE to a readable PEM bundle and retry.' The actual default guidance says '...to add it while retaining public trust. Use REQUESTS_CA_BUNDLE only to replace the complete Requests trust set. See: ...'. The drift predates this PR, but the new paragraph points readers straight at that block.
    Suggested: Make the sample text match the default guidance word for word.

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

Folds the microsoft#2602 panel follow-ups (all inside the microsoft#2035 scope record's
"update directly affected troubleshooting and usage guidance"):

- ssl-issues.md: replace "keep the setting if it is intentional" with
  the owner's safe next action for intentional replacement and opt-out
  settings (doc-writer FU-1), and align the Symptoms sample with the
  real default hint text (doc-writer FU-4).
- common-errors.md: collapse the repeated paragraph into one sentence
  that defers to the hint and the existing SSL issues link, so the
  opt-out-only case is not misdescribed (doc-writer FU-2).
- tls_trust.py: reword the replacement+opt-out clause as an explicit
  "If you unset <setting>, APM_DISABLE_TRUSTSTORE still applies" warning
  (devx-ux-expert FU-3); owner and CLI regressions updated.

Co-authored-by: aryansk <[email protected]>
Co-authored-by: Copilot App <[email protected]>
@danielmeppiel Daniel Meppiel (danielmeppiel) changed the title fix: report TLS trust source in apm doctor fix: match TLS failure hint to the selected trust mode Nov 12, 2026
@danielmeppiel

Copy link
Copy Markdown
Collaborator

APM Review Panel: ship_now

All four prior follow-ups folded, six delta panelists unanimous at zero findings, CI green -- ready to ship.

panel-mode=delta; personas=doc-writer,devx-ux-expert,test-coverage-expert,python-architect,supply-chain-security-expert,auth-expert,apm-ceo

cc Aryan Singh K. (@aryansk) Daniel Meppiel (@danielmeppiel) Sergio Sisternes (@sergio-sisternes-epam) -- a fresh advisory pass is ready for your review.

Delta since the last advisory (c9ae9a1 -> 8e4d033): all four follow-ups from the full pass are folded (ssl-issues safe next action, common-errors collapse, replacement+opt-out clause reword, Symptoms sample aligned); all six Copilot threads on the original doctor diff are replied and resolved; the PR title and body now reflect the #2035 scope and close it.

The delta commit 8e4d033 addresses every follow-up the full-pass panel raised at c9ae9a1. ssl-issues.md now provides the owner's safe next action for intentional replacement and opt-out settings instead of the inert 'keep the setting if it is intentional'. common-errors.md collapses the redundant TLS paragraph to a one-sentence pointer. The replacement+opt-out fallback clause in tls_trust.py is reworded from the ambiguous 'without that replacement' to the explicit 'If you unset {setting}, APM_DISABLE_TRUSTSTORE still applies', with test assertions updated to pin the new wording. The ssl-issues.md Symptoms sample block is aligned with the actual default guidance text. All four changes are surgical, in scope, and verified by the delta panelists.

Six panelists reviewed the delta independently and returned zero findings. The doc-writer confirms the folds match the tls_trust.py guidance strings with no new inaccuracy. The devx-ux-expert confirms the reworded fallback clause resolves the prior ambiguity. The test-coverage-expert confirms both tests pin the opt-out-survives-unset promise with the old wording fully removed. The python-architect, supply-chain-security-expert, and auth-expert each confirm the delta introduces no architectural change, no verification weakening, and no credential surface impact. CI is fully green at head (23 pass, 3 skipping, license/cla pass), main is merged with no drift, and the full CI lint mirror is clean. All six Copilot review threads from the original diff are replied and resolved.

Aligned with: Secure by default: Guidance remains truthful per trust mode and never suggests disabling verification; the delta only improves clarity of the safe next action.; Pragmatic as npm: The ssl-issues.md and common-errors.md folds close the last gap between the owner's actionable advice and what users actually read.; OSS community driven: Community contributor Aryan Singh K. (@aryansk)'s branch carries all folds with contributor authorship preserved; full governance cycle complete.

Panel summary

Persona B R N Takeaway
Python Architect 0 0 0 Delta is a single guidance-string reword inside the canonical TLS owner, with matching test assertions and doc paragraphs. No architectural change.
DevX UX Expert 0 0 0 Delta resolves prior ambiguity nit; reworded fallback clause is clear. Doc edits stay consistent with code output. No new UX regressions.
Supply Chain Security Expert 0 0 0 Delta rewords TLS guidance string and docs. No verification weakening, no credential leaks, no unsafe advice. All paths still fail-closed and steer toward complete CA bundles.
Auth Expert 0 0 0 Delta rewrites TLS trust-store guidance strings and matching test assertions; no token, credential, or AuthResolver surface touched. Auth-neutral.
Doc Writer 0 0 0 All three prior doc findings are fixed in 8e4d033, and the folds match tls_trust.py guidance strings. No new inaccuracy found. Ship.
Test Coverage Expert 0 0 0 Delta is assertion-only reword; both tests pin the opt-out-survives-unset promise; old wording fully removed; no gap.

B = blocking-severity findings, R = recommended, N = nits.
Counts are signal strength, not gates. The maintainer ships.

Recommendation

All four follow-ups from the full-pass advisory are folded and verified. Zero findings across six delta panelists. CI green, no drift, all review threads resolved, PR body closes #2035, title updated to match scope. No remaining items.


Full per-persona findings

Python Architect

No findings.

DevX UX Expert

No findings.

Supply Chain Security Expert

No findings.

Auth Expert

No findings.

Doc Writer

No findings.

Test Coverage Expert

No findings.

This panel is advisory. It does not block merge. Re-apply the
panel-review label after addressing feedback to re-run.


Generated by autopilot-pr-review-worker. This comment is AI-generated and may contain errors.

@danielmeppiel

Copy link
Copy Markdown
Collaborator

Lane L: main merged for landing

  • Pre-merge head: 8e4d03394ce2d628a7b07a364f088173bb9a4153
  • Merged origin/main c2c2e0d72c8e8c88f143099c73f40720b6529a4e (clean merge; GitHub reported DIRTY only on CHANGELOG.md, which this repo merges with merge=union).
  • New head: 65ca71830ad45126ffdc184af75eb279ae8105a7
  • CHANGELOG: moved 1 bullet(s) in '### Fixed' after entry Add ARM64 Linux support to CI/CD pipeline #4 of 18, so queued PRs no longer collide at the section head while landing serially.
  • Lint: ruff check + ruff format --check silent at the new head; CI green at the new head.
  • Owner-touch report regenerated at the new head; every recorded functional test was re-run at that exact head and passed (one process at a time, no xdist).
  • Push: git push https://github.com/aryansk/apm.git HEAD:refs/heads/fix/2035-doctor-tls-diagnostic (plain push, no force).

This comment was generated by an AI agent (Lane L landing desk) on behalf of Daniel Meppiel (@danielmeppiel).

@danielmeppiel
Daniel Meppiel (danielmeppiel) merged commit baaf9d2 into microsoft:main Nov 12, 2026
26 checks passed
Daniel Meppiel (danielmeppiel) added a commit that referenced this pull request Nov 12, 2026
Clean merge of eight main commits (#3408, #2231, #2602, #3640, #3611,
#3645, #3602, #3646); no lockfile or autopilot package conflicts and
apm audit --ci passes with no drift.

Co-authored-by: sergio-sisternes-epam <[email protected]>
Co-authored-by: Copilot App <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/cli CLI command surface, flags, help text (cross-cutting). area/testing Test infrastructure, fixtures, e2e harness, coverage. status/deferred Not invited for implementation now; no release commitment. triage/recommended Automated advice completed; not human scope approval. type/feature New capability, new flag, new primitive.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add apm doctor tls trust-source diagnostic + test-suite ssl-isolation fixture

4 participants