Repository navigation
Conversation
The fast path in _request_subscripton() builds its response from
subscription_cache, which intentionally omits configfile.config and
configfile.settings (CACHE_EXCLUSIONS). Returning that cache directly as
the response leaks the exclusion into the API, so subscribers receive a
configfile with those two fields silently missing, while the equivalent
HTTP objects/query returns them correctly.
On a U1 running Moonraker 1.6.0 this makes printer.objects.subscribe with
{configfile: null} return only warnings, save_config_pending and
save_config_pending_items, and {configfile: ["settings","config"]} return
an empty object. The shipped Fluidd UI gates its Bed Mesh card on
configfile.settings.bed_mesh, so the card disappears entirely.
Skip the fast path when the caller requested a field that CACHE_EXCLUSIONS
removes from the cache, falling through to a real Klippy query. The
optimization still applies to every other object and to configfile
requests that do not touch the excluded fields.
Fixes Snapmaker#5
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5.
Problem
_request_subscripton()has a fast path that builds its response directly fromsubscription_cache:But that cache is populated with
CACHE_EXCLUSIONSstripped out:So
subscription_cache["configfile"]only ever holds{warnings, save_config_pending, save_config_pending_items}. Upstream Moonraker strips those fields from the cache only — the response is always built from a real Klippy query, so the exclusion stays invisible to clients. Returning the cache as the response leaks the exclusion into the API.Observed on a U1 (Klipper
1.6.0.267_20260815150420, Moonraker1.6.0):configfilekeys returnedGET /printer/objects/query?configfilesettings= 204 sections ✅{configfile: null}warnings,save_config_pending,save_config_pending_items❌{configfile: ["settings","config"]}{}❌The last case is the same root cause:
{k: v for k, v in cached.items() if k in fields}matches nothing.User-visible effect: the Fluidd build shipped on the printer gates its Bed Mesh card on
configfile.settings.bed_mesh != null, so the card vanishes from the Dashboard and Tune pages with no error shown, even thoughprinter.bed_meshis fully populated and correct.Fix
Skip the fast path when the caller asked for a field the cache is known to omit, falling through to a real Klippy query.
This is deliberately minimal — the optimization is preserved for every other object, and for
configfilerequests that don't touchconfig/settings.Verification
I reimplemented the fast-path logic standalone to confirm the behaviour change. Before the patch it reproduces the exact key sets observed on the printer, including the empty-object case:
{configfile: None}{configfile: ["settings","config"]}{}❌{configfile: ["warnings"]}{toolhead: None}python -m py_compilepasses; all added lines are ≤79 chars.Note (not addressed here)
Upstream begins
_request_subscripton()with:That line isn't present in this fork, which is why a connection re-subscribing "covers itself" via
existing_unionand hits the fast path so readily. Restoring it also means a client narrowing its subscription no longer gets the union of its old and new field sets. I left it out to keep this PR minimal, but I'm happy to add it here or in a separate PR if you'd prefer.