fulcro

roklenarcic 2025-03-04T19:28:08.309059Z

Is there a way to get better guardrails messages, I have this config:

{:expound    {:show-valid-values? true
              :print-specs?       true}
 :guardrails/compact?    false
 :guardrails/stack-trace :prune
 }
but I am using malli.

roklenarcic 2025-03-04T19:28:32.507849Z

Here’s an example of message that doesn’t tell me much: Guardrails: -- Validation Error com.fulcrologic.guardrails.malli.core:117 -- Value: nil Errors: [“should be a keyword”] Schema: :keyword More information: https://cljdoc.org/d/metosin/malli/CURRENT ------------------------------------------------------------ Pruned Stack Trace (see gr.utils/last-failure-stacktrace for full trace) [“roklenarcic.edavki.trade$eval15455$open_close__15456.invoke” “trade.clj” 28] called by [“roklenarcic.edavki.trade$eval15469$merge_stats__15470.invoke” “trade.clj” 35] called by [“roklenarcic.edavki.trade_test$fn__18273.invokeStatic” “trade_test.clj” 46] called by [“roklenarcic.edavki.trade_test/fn” “trade_test.clj” 43] called by [“cognitect.test_runner$test.invokeStatic” “test_runner.clj” 74]

roklenarcic 2025-03-04T19:28:58.276749Z

in this case it was return spec that failed but that’s not clear from the text

roklenarcic 2025-03-04T19:33:35.740769Z

Another issue is that when I have a vector of maps, if there’s a spec failure it shows me the wrong value, but not any siblings in map so when the vector has 500 maps with 20 props each it is hard to find out which one is wrong. E.g.:

Guardrails:
-- Validation Error  com.fulcrologic.guardrails.malli.core:117 --

Value:

  [[... {:roklenarcic.edavki.security/sym 1}]]

Errors:

  [[nil
    {:roklenarcic.edavki.security/sym ["should be a string"
                                       "should be a string"]}]]

Schema:

  [:sequential :roklenarcic.edavki.trade/lot]
Here if I could see the rest of the map I would be able to see the :id key and I would be able to find the offending data instantly.

tony.kay 2025-03-04T22:03:22.420729Z

isn’t that telling you that the sym key should be a sequence of lot, which I guess are strings?

tony.kay 2025-03-04T22:03:33.476449Z

it’s filtering OUT the stuff that passed

tony.kay 2025-03-04T22:04:29.546819Z

oh, I see…you’re saying that there is an item in the collection, and you’d like to know which one

roklenarcic 2025-03-04T22:04:47.190099Z

Sure the rest of the keys passed, but it’s kinda hard to know which item has this property, unless I boot the debugger and find the one that has sym 1

tony.kay 2025-03-04T22:04:50.624129Z

The schema messages are generated by malli. Talk to them 😄

tony.kay 2025-03-04T22:05:24.653199Z

I’m open to PRs in GR that improve whatever you want…but tap> is there so you could use Portal or something to see the failing value that way

tony.kay 2025-03-04T22:06:53.074739Z

the general problem is quite hard: How do I make a generic tool that gets any possible data of any format in the world, and tells you what is wrong with that (arbitrarily large) data?

tony.kay 2025-03-04T22:07:22.518509Z

you want the :id, someone else wants the vector offset, someone else wants a java object turned into a map via bean, etc.

roklenarcic 2025-03-04T22:07:31.946259Z

yeah I understand

tony.kay 2025-03-04T22:07:38.930549Z

almost no one wants a vector of 500 itesm with 20 keys each 😄

roklenarcic 2025-03-04T22:07:40.490709Z

does the value go into tap?

tony.kay 2025-03-04T22:08:00.079739Z

Honestly I don’t remember where tap is used. I didn’t write that part of GR…I just know it is there

tony.kay 2025-03-04T22:08:07.707469Z

check out the source

roklenarcic 2025-03-04T22:14:03.964159Z

doesn’t seem to be the case, I tried add-tap println and nothing gets printed when calling function with wrong argument types

tony.kay 2025-03-04T22:21:50.471129Z

? I don’t understand. It’s a GR config option

tony.kay 2025-03-04T22:21:58.676889Z

you tell GR that you want to tap

tony.kay 2025-03-04T22:22:01.855519Z

see docs

roklenarcic 2025-03-04T22:54:46.356669Z

Ok, thanks