plumatic / schema

Clojure(Script) library for declarative data description and validation
Other
2.4k stars 256 forks source link

Restricting extra keys causes memory leak in compojure-api #433

Open frenchy64 opened 2 years ago

frenchy64 commented 2 years ago

The fix https://github.com/plumatic/schema/pull/415 reportedly causes a memory leak in compojure-api, which assumes keys of a map schema never change their equality: https://github.com/metosin/compojure-api/issues/454

frenchy64 commented 2 years ago

@gfredericks is there another solution to this? Could we move this code to the generators lib instead?

gfredericks commented 2 years ago

It does seem like moving it to generators would be better.

Looking back at it it seems like this is where you'd want to do the filtering, but at this point in the code we only have the spec, not the schema: https://github.com/plumatic/schema-generators/blob/b0ecf2c8659ca985144c74e4be2a5a7c9e55596f/src/schema_generators/generators.cljc#L78

Line 211 presumably could add some information to the spec (as metadata?); I'm not 100% sure that it's safe to just check if the schema is a map and look for keys that aren't a special type, but if so then seems like it would work.