Skip to content

fix: structured standalone detail for missing map keys (#107) - #245

Open
felipeofdev-ai wants to merge 1 commit into
nubank:masterfrom
felipeofdev-ai:fix/107-missing-keys-detail
Open

felipeofdev-ai wants to merge 1 commit into
nubank:masterfrom
felipeofdev-ai:fix/107-missing-keys-detail

Conversation

@felipeofdev-ai

Copy link
Copy Markdown

Summary

  • Restructure matcher-combinators.standalone/match :mismatch/detail when map mismatches include missing keys.
  • Surface :missing-keys, :missing (expected values), and :unexpected-keys instead of embedding Missing records that read like partial mismatches.
  • Add regression tests and README standalone docs.

Why

When an expected map key is absent, the standalone API returned entries like :a #Missing{:expected 1} inside the detail map. That reads like a value mismatch missing an :actual field rather than an absent key — exactly the ambiguity @dchelimsky described in #107 and the TODO in standalone_test.clj.

Example before:

(standalone/match (m/equals {:a 1}) {:b 2})
;; :mismatch/detail {:b #Unexpected{:actual 2}, :a #Missing{:expected 1}}

After:

(standalone/match (m/equals {:a 1}) {:b 2})
;; :mismatch/detail {:value {:b 2}
;;                   :missing-keys [:a]
;;                   :missing {:a 1}
;;                   :unexpected-keys [:b]}

Core match results and pretty-print output are unchanged; only the standalone :mismatch/detail shape changes when missing keys are present. Value mismatches on present keys keep the prior annotated-map shape.

Fixes #107

Test plan

  • clojure -M:dev:clj-test:test-runner (78 tests, 0 failures)
  • clojure -M:dev:clj-test:test-runner -n matcher-combinators.standalone-test
  • Full CI (bb test — cljs + midje)

— Felipe Oliveira Fernandes · Systems & Agentic AI Engineer
https://github.com/felipeofdev-ai · https://felipeofdev-ai.github.io/

Made with Cursor

Surface :missing-keys and :missing in standalone :mismatch/detail when expected map keys are absent, instead of embedding Missing records that read like partial mismatches.

Signed-off-by: Felipe Fernandes <felipe.of.dev@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improve :mismatch/detail for missing keys

1 participant