Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

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

Closed Beginner friendly
#3,167 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@MohammedAlkindi is already working on this.

Since Oct 9, 2026.

  • #3199 by @MohammedAlkindi — open
  • #3211 by @abhishekacharya200 — open

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
90/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
python
Domain
cli

Research direction

Start from src/apm_cli/integration/hook_native_formats.py: run the issue's repro snippet (json.dumps(_to_claude_hook_entries([{'bash': 'echo test', 'env': {'APM_TEST': 'value'}}]))) to see the mappingproxy failure, then trace where dict(handler.metadata), dict(binding.metadata) and the raw-entry paths only shallow-copy frozen IR produced by _freeze in src/apm_cli/hook_contract.py. Add a recursive materializer (Mapping -> dict, list/tuple -> list, scalars preserved) applied to handler, binding and raw entries in both nested and flat rendering paths. Done when the repro serializes, the existing hook adapter tests still pass, and new tests cover JSON round trips for Claude/Codex/Gemini/nested-flat Antigravity, nested env preservation, and non-mutation of the frozen IR.

Written by the indexing model from the issue text.

Description

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.
Dominant language
Python
Stars
4k
Forks
393
Avg merge
4d 23h
Merged PRs (30d)
62

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/apm

All issues in microsoft/apm

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.