Repository navigation
fix(lockfile): an unsupported lockfile version names both remedies - #4469
Merged
Merged
Conversation
…egenerate or upgrade APM (#4233) Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 20, 2026 18:42
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
Co-authored-by: copilot-swe-agent[bot] <[email protected]>
5 of 10 tasks
…it --ci - run_baseline_checks still needs LockFile at runtime (NameError in audit --ci). - The remedy helper becomes UnsupportedLockfileVersionError.for_path, keeping deps/lockfile.py under the 2100-line guard. - install/service.py stays within its 1000-line budget. Co-authored-by: Copilot App <[email protected]>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved lockfile-handling issues can misdirect global-lock recovery, abort policy-enabled CI audits before reporting failures, and omit regeneration guidance when both schema and generator versions are newer.
3 open issues
What changed in this PR
This PR addresses #4233 by adding regeneration and upgrade advice to unsupported-lockfile-version errors, using the remediation catalog introduced in #4143.
Changes:
- Adds catalog entries and path-bound remedies to unsupported-version errors.
- Updates install, lock and CI audit error handling.
- Adds installed-CLI coverage for diagnostics, unchanged project files and regeneration.
| File | Description |
|---|---|
tests/unit/core/test_remediation_commands_catalog.py |
Records validation coverage for the new remedies. |
tests/integration/test_unsupported_lockfile_version_lifecycle.py |
Tests failure diagnostics, state preservation and recovery. |
tests/fixtures/lifecycle_bug_ledger.json |
Links issue #4233 to its regression test. |
src/apm_cli/policy/ci_checks.py |
Reports unsupported versions as failed baseline checks. |
src/apm_cli/install/service.py |
Avoids conflicting generic advice during frozen installs. |
src/apm_cli/install/audit_replay.py |
Converts unsupported versions into replay errors. |
src/apm_cli/deps/lockfile.py |
Attaches path-aware remedies to unsupported-version exceptions. |
src/apm_cli/core/remediation.py |
Defines regeneration and APM upgrade advice. |
src/apm_cli/commands/lock.py |
Adds the [x] symbol to generic lock-generation errors. |
src/apm_cli/commands/audit.py |
Skips drift parsing for unsupported lockfile versions. |
CHANGELOG.md |
Documents the improved recovery diagnostic. |
Review effort: Balanced
Comment on lines
+256
to
+258
| regen = remediation.LOCKFILE_VERSION_UNSUPPORTED.bind(path=path.name) | ||
| if is_user_scope_root(path.parent): | ||
| regen = regen.with_command("apm lock -g") |
Comment on lines
+1847
to
+1848
| except UnsupportedLockfileVersionError as exc: | ||
| raise exc.for_path(path) from exc |
| result = CIAuditResult() | ||
| lockfile_path = get_lockfile_path(project_root) | ||
| lock = LockFile.read(lockfile_path) | ||
| lock, unreadable = _read_audited_lock(lockfile_path) |
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…es both remedies Co-authored-by: Copilot App <[email protected]> # Conflicts: # tests/fixtures/lifecycle_bug_ledger.json
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
Co-authored-by: Copilot App <[email protected]>
…module The remedy for a lockfile version this APM cannot read moves to deps/lockfile_version_remedy.py (with_version_remedy); lockfile.py keeps one import, staying within its line budget on the train. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…ead-only-lockfile-path) Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 20, 2026
…; audit reads the lockfile guarded (#4469 x #4495) (04daadaf) Co-authored-by: Copilot App <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Description
A lockfile with an unsupported
lockfile_version(one written by a newer APM) failed every lockfile reader with a bareUnsupported lockfile version '99'; supported versions: 1, 2, 3, 4. It offered no way out.apm audit --cireached the generic top-levelError:handler without an[x]line, andapm install --frozenappended unrelated "fix the file" advice. OpenAPM req-lk-004 requires the diagnostic to offer both remedies.Every reader now fails with exit 1 and an
[x]diagnostic naming both remedies, rendered from the remediation catalog (core/remediation.py, from #4143):core/remediation.py: two catalog entries.lockfile-version-unsupportedisapm lockwith the step "move {path} aside" first.lockfile-version-upgrade-apmisapm self-update. The lockfile stays fail-closed:apm locknever silently downgrades a newer lock, so the regenerate remedy names the move-aside step.deps/lockfile.py:LockFile.read()and the write path's existing-lock check raiseUnsupportedLockfileVersionErrorwith both remedies bound to the lock's path. A user-scope lock getsapm lock -g. The error also carries the structured remediations.policy/ci_checks.py:apm audit --cireports it as a failedlockfile-existscheck, with both remediations in JSON and SARIF.commands/audit.pydrift detection skips that lock instead of crashing.install/audit_replay.pyreports it as a replay error.install/service.py:--frozenprints the remedies without the contradicting generic advice.commands/lock.pyprints its error with[x].Issue and approved scope
Fixes #4233 (scope record: #4233 (comment))
Human scope-approval comment: #4233 (comment)
Does this PR complete the issue, or what remains? It completes it. It is stacked on #4143 (remediation catalog) and based on that branch; once #4143 merges it retargets to
main.Type of change
Testing
New
tests/integration/test_unsupported_lockfile_version_lifecycle.py(installed CLI,lifecycle_smoke, req-lk-004). For each ofinstall,install --frozen,lockandaudit --ciagainst alockfile_version: "99"lock, it asserts:[x]line;It then follows the printed regenerate remedy literally (moves the named file aside, runs the printed
apm lock) and asserts the lock is rewritten at a supported version.Results:
tests/unit/core(remediation catalog proofs), lockfile, audit, deps and remediation-advice suites: no new failures. The only failures (test_output_mode,test_auth_credential_report,test_bare_cache_sparse) fail the same way without this change.tests/quality/test_lifecycle_bug_ledger.pyandtests/quality/test_test_taxonomy.py: 38 passed.scripts/check_test_assertions.py: no[x].There is no strict xfail for req-lk-004 in
tests/spec_conformance, so nothing to flip. CONFORMANCE is not regenerated.Changelog
## [Unreleased]inCHANGELOG.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regenerated