fulcro

Eva O 2025-04-03T17:19:26.885649Z

I found a bug that I'm not sure if it's in statecharts, guardrails, or malli. If you invoke an external service with a non-keyword id and call (runtime/session-data env session-id) you get an error when guardrails is enabled. I have an SSCCE here: https://github.com/evaogbe/statecharts-invoke-bug Also keyword ids don't work with done.invoke.[invokeid] but that one is less of a bug and more of a gotcha that should be documented.

Eva O 2025-04-03T17:23:18.077129Z

Also the statecharts docs say that the invoke type defaults to statechart when left out, but in actuality the type key is required

Eva O 2025-04-04T12:37:38.792649Z

That makes sense. I think there's an extend-key function that can help with the done.invoke.[id] keyword conversion

tony.kay 2025-04-04T13:13:46.892739Z

yes, I beleive I’ve written such a thing more than once 😛

Eva O 2025-04-04T17:28:13.873189Z

I found a patch for the bug but I still don't know the root cause

- (>def ::sc/elements-by-id [:map-of keyword? ::sc/element])
+ (>def ::sc/elements-by-id [:map-of ::sc/id ::sc/element])

Eva O 2025-04-04T17:31:13.847309Z

It's wrong in both the clojure spec and the malli spec

tony.kay 2025-04-04T18:34:01.175449Z

ah, yes, that should be fixed in the specs

tony.kay 2025-04-04T18:34:30.197679Z

If GR is enabled, then using a non-keyword element ID in the statechart will cause failures

tony.kay 2025-04-04T18:36:30.028419Z

not sure why that spec would affect invocations only though, or how an element would be created with such an ID just from invocation alone

Eva O 2025-04-04T19:03:41.003529Z

It might not be invocation specific. I discovered it while doing invocations because I needed non-keyword ids to work with done.invoke[id]. com.fulcrologic.statecharts.runtime uses malli specs, which might be why it wasn't broken elsewhere

tony.kay 2025-04-04T20:51:17.862569Z

ok, well, if changing that spec fixes it, then that certainly looks like a valid fix to me

Eva O 2025-04-06T00:06:16.598019Z

I've sent in PRs with the fixes

tony.kay 2025-04-03T21:52:53.053519Z

not terribly surprised. invocation support is sort of platform specific and I’ve not heavily hammered on it.

Eva O 2025-04-03T23:15:09.591529Z

I think either the docs need to be updated or the code needs to be fixed to match the docs. I can send in a PR for the direction you'd prefer

tony.kay 2025-04-04T05:17:08.891999Z

Yeah, I probably should not have used keywords for the done.invoke stuff. Perhaps if a keyword is used (the specs support keyword) we should call name on it for the event invokeid, or some such conversion 😕 session IDs are spec’d to support UUID, string, numbers, and keywords. But the creation of events that are based on these IDs don’t work well this way. Event names are definitely wired to keywords, so some kind of standard transform needs to apply. Session ID of :x.y.z/id -> :done.invoke.x.y.z/id ?