Skip to content

Map () to nil when converting callback results - #88

Merged
CaitlynMainer merged 1 commit into
PC-Logix:main-MC1.21.1from
Fingercomp:map-unit-result-to-null
Aug 27, 2026
Merged

Map () to nil when converting callback results#88
CaitlynMainer merged 1 commit into
PC-Logix:main-MC1.21.1from
Fingercomp:map-unit-result-to-null

Conversation

@Fingercomp

Copy link
Copy Markdown

To return nil from a component @Callback, it has to pass either null or None to the result function, though previously all callbacks used null exclusively. The vibeport apparently didn't get the memo, so in its misguided attempt to stick to Scala conventions it replaced a bunch of these nulls with ().

Now, () is neither null nor None, so the Registry did not map it to nil. In fact, the Registry didn't have an explicit case for it at all, so it defaulted to converting it to string. As a result, all those methods that the vibefork tampered with started returning "()", errorMessage instead of nil, errorMessage.

This PR fixes this by adding () to the list of values that represent nil (meaning now you can use either null, None, or ()). However, the code remains inconsistent, as half the calls uses () and the other half keeps passing null. It might be a good idea to commit to either choice: replace () with null or vice versa. (I prefer () personally, FWIW.)

Whenever a callback wants to return a `nil` value, it has to pass
either `null` or `None` to the `result` function (in fact, previously
all the code used `null` exclusively). But I guess the vibeport really
wanted to follow Scala conventions because it replaced these nulls with
`()` in a lot of places, which the Registry did not handle explicitly,
falling back to stringifying it during the conversion. As a result, a
bunch of methods returned `"()", errorMessage` where before it would've
been `nil, errorMessage`.

This commit adds an explicit case for `()` in the conversion routine so
that `()` gets mapped to `nil`, fixing all of these methods.
@CaitlynMainer
CaitlynMainer merged commit 2523032 into PC-Logix:main-MC1.21.1 Aug 27, 2026
1 check passed
@Fingercomp
Fingercomp deleted the map-unit-result-to-null branch August 27, 2026 21:20
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.

2 participants