Repository navigation
fix(hooks): serialize nested hook metadata in native hook files - #3199
Closed
Mohammed Alkindi (MohammedAlkindi) wants to merge 1 commit into
Closed
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
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.
7 of 17 tasks
Daniel Meppiel (danielmeppiel)
added a commit
to abhishekacharya200/apm
that referenced
this pull request
Oct 16, 2026
Select nonredundant regression assets from microsoft#3199 commit b36ed0f for the approved microsoft#3167 scope. Keep microsoft#3211 as the sole implementation and its canonical _thaw unchanged. Prove binding/raw/source independence and normal approved local install/update without executing hooks. Co-authored-by: Mohammed Alkindi <alkndymhmd692@gmail.com> Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Daniel Meppiel (danielmeppiel)
added a commit
to abhishekacharya200/apm
that referenced
this pull request
Oct 19, 2026
Faithfully integrate released main and its registry mutation matrix repair. Preserve the dated release text, original contributor history, and the sole microsoft#3211 hook-rendering implementation with credited microsoft#3199 tests. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f79e464c-180e-4be3-9056-0773aa679a1a
Contributor
Author
|
Closing in favour of #3211, which merged with the regression tests from this PR. |
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.