Repository navigation
fix(hooks): serialize nested hook metadata in native hook files - #3199
Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Open
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Conversation
The hook IR freezes dicts into MappingProxyType and lists into tuples. Claude, Codex, Gemini and Antigravity rendering copied handler and binding metadata with a shallow dict() and appended raw entries as-is, so a nested value such as an env object reached json.dumps as a mappingproxy and install/update failed. Render through a recursive _thaw() that rebuilds plain dicts and lists, so output is JSON-serializable and independent of the frozen IR. Fixes microsoft#3167
Copilot started reviewing on behalf of
Mohammed Alkindi (MohammedAlkindi)
October 9, 2026 22:06
View session
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The fix consistently covers all affected rendering paths with focused regression tests and matching documentation.
0 open findings
What changed in this PR
Fixes native hook serialization by recursively converting frozen IR metadata into mutable JSON-compatible containers.
Changes:
- Adds recursive metadata thawing across native hook renderers.
- Adds unit and install-level regression coverage.
- Updates hook authoring documentation and changelog.
| File | Description |
|---|---|
src/apm_cli/integration/hook_native_formats.py |
Recursively materializes metadata before rendering. |
tests/unit/integration/test_hook_native_formats.py |
Covers serialization, metadata preservation, and isolation. |
tests/integration/test_hook_nested_metadata_install_e2e.py |
Verifies installation writes nested metadata. |
docs/src/content/docs/producer/author-primitives/hooks-and-commands.md |
Documents nested metadata preservation. |
CHANGELOG.md |
Records the bug fix. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch has not been deployed
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
Nested hook metadata such as an
envobject fails install/update withObject of type mappingproxy is not JSON serializable: renderers shallow-copied the frozen IR. A recursive_thaw()now rebuilds plain dicts and lists at the render boundary, keeping the IR immutable. New unit andapm installe2e tests: 14 passed.Issue and approved scope
Issue: #3167
Human scope-approval comment: #3167 (comment)
Fixes #3167, completing it.
Type of change
Testing
Spec conformance (OpenAPM v0.1)
docs/src/content/docs/specs/openapm-v0.1.mdupdateddocs/src/content/docs/specs/manifests/openapm-v0.1.requirements.ymlupdated.@pytest.mark.req("req-XXX")test undertests/spec_conformance/added or extended.CONFORMANCE.{md,json}regenerated viauv run --extra dev python -m tests.spec_conformance.gen_statementand committed.