Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

[BUG] APM 0.33.0: apm update fails to integrate Azure Skills because frozen hook metadata is not JSON serializable

Aperta Adatta ai principianti
#3,167 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

@MohammedAlkindi ci sta già lavorando.

Dal 9/10/2026.

  • #3199 di @MohammedAlkindi — aperta
  • #3211 di @abhishekacharya200 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
90/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
python
Ambito
cli

Direzione di ricerca

Inizia da src/apm_cli/integration/hook_native_formats.py: esegui lo snippet di riproduzione dell'issue (json.dumps(_to_claude_hook_entries([{'bash': 'echo test', 'env': {'APM_TEST': 'value'}}]))) per vedere l'errore mappingproxy, poi traccia dove dict(handler.metadata), dict(binding.metadata) e i percorsi delle voci grezze fanno solo una copia superficiale del IR congelato prodotto da _freeze in src/apm_cli/hook_contract.py. Aggiungi un materializzatore ricorsivo (Mapping -> dict, list/tuple -> list, scalari conservati) applicato a handler, binding e voci grezze sia nei percorsi di rendering annidati che piatti. Fatto quando la riproduzione viene serializzata, i test esistenti dell'adapter di hook passano ancora e nuovi test coprono i round trip JSON per Claude/Codex/Gemini/nested-flat Antigravity, la conservazione dell'env annidato e la non mutazione del IR congelado.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

status/accepted type/bug

With APM CLI 0.33.0, apm update fails while integrating microsoft/azure-skills:

[x] 1 package failed:
    +- microsoft/azure-skills -- Failed to integrate primitives: Object of type mappingproxy is not JSON serializable
[x] Installation failed with 1 error(s). 

Environment

  • APM CLI: 0.33.0
  • Reported installation: Windows, WinGet standalone executable and macOS 27.01 (Homebrew)
  • Dependency: microsoft/azure-skills
  • Targets: claude, codex, copilot

Steps to reproduce

Use APM CLI 0.33.0.
Add microsoft/azure-skills to an APM project with the following configuration.
Run apm update.

name: apm-hook-repro
version: 1.0.0
description: Minimal Azure Skills integration reproduction
author: APM user
targets:
  - claude
  - codex
  - copilot
dependencies:
  apm:
    - microsoft/azure-skills

The dependency is not pinned here; reproduction depends on it containing hooks with nested metadata, such as an env object.

Expected behavior

APM integrates the hooks successfully, preserving their environment variables
and other metadata in the generated native JSON documents.

Actual behavior

Integration fails with the error above, and the install transaction is not committed.

Root cause

src/apm_cli/hook_contract.py recursively freezes hook metadata in _freeze:
dictionaries become MappingProxyType instances, and lists become tuples.
This is appropriate for the immutable intermediate representation (IR).

However, src/apm_cli/integration/hook_native_formats.py only makes a shallow
copy with dict(handler.metadata) and dict(binding.metadata). Nested mappings
remain frozen. The raw-entry paths also return frozen metadata directly.
Consequently, JSON serialization fails when it encounters a nested mapping proxy.

The failure can be reproduced without downloading Azure Skills or executing hooks:

import json
from apm_cli.integration.hook_native_formats import _to_claude_hook_entries

entries = [{
    "bash": "echo test",
    "env": {"APM_TEST": "value"},
}]
json.dumps(_to_claude_hook_entries(entries))

Proposed fix

Recursively materialize metadata at the native rendering boundary:

  • Convert Mapping values to new dictionaries.
  • Convert lists and tuples to new lists, recursively converting their elements.
  • Preserve scalar values.
  • Apply the conversion to handler metadata, binding metadata, and raw entries in
    both the nested and flat rendering paths.

Keep the IR immutable. Do not stringify unsupported values with default=str,
discard env, or change dependency declarations as a workaround.

Regression coverage

  • JSON round trips for Claude, Codex, Gemini, and nested/flat Antigravity adapters.
  • Preservation of nested env, extension metadata, arrays, and scalar values.
  • Preservation of commands, timeout conversion, matchers, and provenance.
  • Raw-entry round trips, including mappings inside arrays.
  • Mutation of rendered output does not mutate the source or frozen IR.
  • Gemini's in-place compatibility conversion preserves env.
Lingua principale
Python
Stelle
4k
Fork
387
Merge medio
5g 44m
PR unite (30g)
60

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di microsoft/apm

Tutte le issue di microsoft/apm

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.