Repository navigation
fix(marketplace): marketplace list never creates the user registry (#4600) - #4616
Merged
Daniel Meppiel (danielmeppiel) merged 1 commit intoNov 21, 2026
Conversation
Daniel Meppiel (danielmeppiel)
added a commit
that referenced
this pull request
Nov 21, 2026
Co-authored-by: Copilot App <[email protected]>
Collaborator
Author
|
Parked under the program's open-PR cap for this lane; the branch stays pushed and this PR will be reopened when the lead clears it. |
…4600) Reads of ~/.apm/marketplaces.json treat a missing file as an empty list; only _save (add, remove, manifest sync) creates it. The create-on-read path and read_registered_marketplaces are gone, so every reader goes through the one non-creating _load. The lifecycle receipt T4|marketplace|project|consistent proves on the real CLI that a fresh HOME lists nothing and creates nothing under ~/.apm, that add still creates the registry, and that list keeps an existing registry byte-identical. Co-authored-by: Copilot App <[email protected]>
Daniel Meppiel (danielmeppiel)
force-pushed
the
danielmeppiel-p1-4600-marketplace-list-readonly
branch
from
November 21, 2026 16:47
85a9a10 to
f736e7a
Compare
Daniel Meppiel (danielmeppiel)
marked this pull request as ready for review
November 21, 2026 17:14
Daniel Meppiel (danielmeppiel)
requested a review
from Sergio Sisternes (sergio-sisternes-epam)
as a code owner
November 21, 2026 17:14
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the change making marketplace registry reads side-effect-free.
No open issues 🎉
What changed in this PR
Fixes #4600 by making marketplace registry reads side-effect-free. A missing registry now reads as empty; registration changes create it when needed, preserving listing output and exit codes.
Changes:
- Consolidates registry reads into one non-writing path and moves directory creation into
_save. - Updates reconciliation and project marketplace callers to use the unified reader.
- Adds regression coverage for missing and existing registries, plus a bug-ledger entry and changelog fragment.
| File | Description |
|---|---|
tests/unit/marketplace/test_marketplace_registry.py |
Tests non-creating reads and updates registry fixtures. |
tests/lifecycle/test_marketplace_registry_reads.py |
Verifies read-only listing and first-registration writes through the CLI. |
tests/fixtures/lifecycle_bug_ledger/bugs/4600.json |
Records the bug and links regression tests. |
src/apm_cli/marketplace/registry.py |
Makes reads non-creating and consolidates the reader API. |
src/apm_cli/marketplace/reconcile.py |
Uses the unified registry reader during reconciliation. |
src/apm_cli/marketplace/project_marketplaces.py |
Uses the unified reader for shadowed-registration notices. |
changelog.d/4616.fixed.md |
Documents the user-visible listing fix. |
Review effort: Balanced
Daniel Meppiel (danielmeppiel)
deleted the
danielmeppiel-p1-4600-marketplace-list-readonly
branch
November 21, 2026 18:30
This was referenced Nov 21, 2026
Merged
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
TL;DR —
apm marketplace listis a read command, but on a fresh HOME it created~/.apm/marketplaces.json({"marketplaces": []}). The registry owner,src/apm_cli/marketplace/registry.py, now reads a missing registry as empty and creates the file only on the first real write. Output and exit codes are unchanged.Closes #4600
Dependency order: independent. Interacts with #4604: whichever lands second drops/flips the #4600 known cell (
KNOWN_T4/DRIFT_KNOWN_CELLS) and regenerates obligations.Problem (WHY)
_load()defaulted tocreate=Trueand called_ensure_file(), so every reader that usedget_registered_marketplaces()(includingmarketplace list,marketplace_names,get_marketplace_by_name) wrote~/.apm/marketplaces.jsonwhen it was missing.tests/lifecycle/oracles.py) flags it:marketplace wrote home:['.apm/marketplaces.json'].get_registered_marketplacescreating,read_registered_marketplacesnot). Readers could pick the wrong one.Approach (WHAT)
_load(create=True)→_ensure_file()writes{"marketplaces": []}_load()never writes; a missing file reads as[]_saverelied on_ensure_file()_savecreates$APM_HOME(mode 0700) and writes atomically (unchangedos.replace)get_registered_marketplaces/read_registered_marketplacesget_registered_marketplaces;read_registered_marketplacesremoved and its 2 callers repointedImplementation (HOW)
src/apm_cli/marketplace/registry.py_ensure_fileand thecreateflag;_savemakes the config dir itself.src/apm_cli/marketplace/project_marketplaces.py,reconcile.pyget_registered_marketplaces(already non-creating semantics).tests/lifecycle/test_marketplace_registry_reads.py(new)tests/unit/marketplace/test_marketplace_registry.pytest_reads_never_create_the_registry; fixtures no longer call the removed_ensure_file.tests/fixtures/lifecycle_bug_ledger/bugs/4600.json,changelog.d/4616.fixed.mdTrade-offs
check_obligation, buttests/quality/lifecycle_obligations.jsonis not regenerated here, so the generated obligation staysbaselineuntil test(lifecycle): M-SCOPE-LOCK drift spine for stale and absent lockfiles (T-3 batch 1) #4604 (or a follow-up) credits it. This keeps the two PRs independent.read_registered_marketplacesrather than keeping an alias. Both names would have meant the same thing; one reader keeps the owner single.removeof an unknown name still takes the mutation lock (may create$APM_HOMEand its.lock); registry format and location are unchanged.Benefits
apm marketplace liston a fresh HOME creates nothing under~/.apm(verified by snapshot, not by string compare).Issue and approved scope
Issue: Closes #4600
Human scope-approval comment: #4600 (comment)
Does this PR complete the issue, or what remains? Complete. The cell
T4|marketplace|project|consistentearns a passing receipt that fails on main; controls and ledger/changelog rows are included.Type of change
Testing
Scenario evidence
Validation commands and results
Engine driver (PR default),
env -u GIT_EXEC_PATH "PATH=/usr/bin:/bin:$PATH" APM_BINARY_PATH=$PWD/.venv/bin/apm, run through the host guard:python -m pytest tests/lifecycle/test_marketplace_registry_reads.py -n 0on main'ssrc/I5 (each command writes only its declared write set): marketplace wrote home:['.apm/marketplaces.json']python -m pytest tests/lifecycle/test_marketplace_registry_reads.py tests/unit/marketplace tests/unit/test_thread_safety.py tests/unit/test_outdated_marketplace.py tests/unit/test_outdated_marketplace_detection.py tests/quality/test_lifecycle_bug_ledger.py -n 0python -m pytest tests/unit/marketplace/test_marketplace_registry.py tests/unit/test_view_command.py tests/unit/test_state_leak_detector.py -n 0uvx [email protected] check/format --check(CI paths)pylint R0801 --min-similarity-lines=10bash scripts/lint-auth-signals.shpython scripts/check_complexity_ratchet.py --base-ref origin/main[+] complexity ratchet cleanpython -m tests.quality.taxonomy --changed[+] tm006: 2 changed test module(s) carry their marker and promisepython scripts/check_test_assertions.py[+] assertion-quality ratchet cleanbash tests/spec_conformance/mode_b_detector.sh[+] mode_b: no critical-path diff; OK0f9b391:pytest tests/lifecycle/test_marketplace_registry_reads.py tests/unit/marketplace/test_marketplace_registry.py -n 0pytest tests/quality/test_lifecycle_bug_ledger.pychangelog_fragments.py check/check-unreleased --base-ref origin/main[+] 1 changelog fragment(s) valid/[+] no new bullets under ## [Unreleased]How to test
mkdir -p /tmp/h /tmp/p && cd /tmp/p && HOME=/tmp/h apm marketplace list→[i] No marketplaces registered. ..., exit 0ls /tmp/h/.apm/marketplaces.json→ no such fileHOME=/tmp/h apm marketplace add <source>→/tmp/h/.apm/marketplaces.jsonexists;apm marketplace listshows it and leaves the file bytes unchangedChangelog
changelog.d/4616.fixed.md(replaces a line under## [Unreleased]inCHANGELOG.md):user-visible effect first, 25 words or fewer, ending with
(#PR);breaking changes only under upgrade notes; no Highlights; see
.github/instructions/changelog.instructions.md.Spec conformance (OpenAPM v0.1)
CONFORMANCE.{md,json}regeneratedCo-authored-by: Copilot [email protected]