Skip to content

Read JSON fields with ok/err, not some/none - #5

Merged
DerekCorniello merged 2 commits into
mainfrom
fix/http-server-accessors
Aug 21, 2026
Merged

Read JSON fields with ok/err, not some/none#5
DerekCorniello merged 2 commits into
mainfrom
fix/http-server-accessors

Conversation

@DerekCorniello

Copy link
Copy Markdown
Contributor

Json accessors return result<T, string> now, so the wrong kind reports what it found instead of a bare none (muxlang/mux-compiler#404).

The example benefits from the change it was written to track: status is not an int becomes a message saying what the field actually held.

Needs a compiler with that change to run, so hold until the release ships.

Json accessors return result<T, string> now, so the wrong kind reports what
it found instead of a bare none (muxlang/mux-compiler#404).

The example benefits from the change it is tracking: "status is not an int"
becomes a message saying what the field actually held.

Needs a compiler with that change to run.
@greptile-apps

greptile-apps Bot commented Aug 20, 2026

Copy link
Copy Markdown

Greptile Summary

This PR updates the HTTP server example for JSON accessors that now return result<T, string>.

  • Replaces some/none matching with ok/err.
  • Preserves accessor diagnostics so wrong-kind errors describe the actual JSON value encountered.

Confidence Score: 5/5

The PR appears safe to merge once the required compiler release is available.

No blocking failure remains; both changed error arms now propagate the accessor-provided diagnostic.

Important Files Changed

Filename Overview
examples/http_server/main.mux Updates string and integer JSON field accessors to handle result values and return the detailed accessor error; the previously discarded diagnostic is now preserved.

Reviews (2): Last reviewed commit: "Pass the accessor error through instead ..." | Re-trigger Greptile

Comment thread examples/http_server/main.mux Outdated
The err arms returned the old generic <not a string> / <not an int>, so the
example converted to ok/err without showing what the conversion is FOR - a
wrong-typed field still printed a message that says nothing about what was
there.

The accessor now reports 'expected a string, found an int', so that is what
the example prints.

Caught in review.
DerekCorniello added a commit to muxlang/mux-website-api that referenced this pull request Aug 21, 2026
The image pulls the release tarball for this version, so this cannot be
deployed until v0.10.0 is tagged in mux-compiler. Merging it early is fine;
building it early is not.

0.10.0 is what the docs are written against: muxlang/mux-website#59 and
muxlang/mux-examples#5 are both red purely because they compile against the
released compiler, which still has optional accessors and no from_json.
@DerekCorniello
DerekCorniello merged commit 7a6a4d4 into main Aug 21, 2026
2 of 3 checks passed
@DerekCorniello
DerekCorniello deleted the fix/http-server-accessors branch August 21, 2026 02:22
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.

1 participant