Skip to content

fix(spoolman): resolve escaped quotes issues in filament sub_type metadata#489

Open
BigMcRat wants to merge 41 commits into
paxx12-snapmaker-u1:developfrom
BigMcRat:fix-spoolman-quotes
Open

fix(spoolman): resolve escaped quotes issues in filament sub_type metadata#489
BigMcRat wants to merge 41 commits into
paxx12-snapmaker-u1:developfrom
BigMcRat:fix-spoolman-quotes

Conversation

@BigMcRat

@BigMcRat BigMcRat commented May 29, 2026

Copy link
Copy Markdown

Problem

The Spoolman API handles custom fields formatted as 'Text' by serializing strings with escaped inner quotes (e.g., "\"plus_HS\""). When Moonraker proxies this payload down to Klipper, Python retains the inner literal quotes ('"plus_HS"').

As a result, the backend passes the uncleaned string further down to the Snapmaker core subsystem (print_task_config.py). This forces the touch screen system to generate an invalid format inside print_task.json (visible as sub_type:"plus_HS" with unwanted quotation marks inside the gui.log).

Solution

This patch intercepts the incoming data directly at the Moonraker proxy gate inside spoolman.py.

  • Added a recursive JSON structure cleaner (clean_json_structure) to process incoming payloads dynamically.
  • Used .strip('"') on all strings to cleanly shave off native or nested literal quotation marks at the flanks of the metadata entries.
  • Appended secondary .replace() rules to filter out any lingering internal backslashes (\) or multi-escaped quotation characters.
  • Applied this safety net successfully to rpc_spoolman_proxy endpoint.

Verification

Successfully live-tested via manual hot-swapping inside the printer's RAM.
Verified via moonraker.log:

  • BEFORE: {"id": 45, "filament": {"extra": {"sub_type": "\"plus_HS\""}}}
  • AFTER: {"id": 45, "filament": {"extra": {"sub_type": "plus_HS"}}}

paxx12 added 30 commits May 19, 2026 18:00
… RFID cards

- Move filament config methods from AFC_lane to AFC_lane_spoolman
- Auto-detect RFID cards and bind to Spoolman spools via lot_nr field
- Support comma-delimited card_uid values in lot_nr (card_uid:XXX,card_uid:YYY)
- Add SET_SPOOL_ID and REFRESH_SPOOL gcode commands per lane
- Implement webhook callbacks for Spoolman proxy integration
- Remove card_uid from other spools when binding to new spool
- Update afc-lite.md with comprehensive Spoolman auto-binding documentation
- Document RFID card detection flow and lot_nr format
- Add gcode commands reference (SET_SPOOL_ID, REFRESH_SPOOL)
- Add respond_info notifications for card binding/unbinding actions
- Update limitations section to reflect now-supported features
- Add automatic card_uid removal from spoolman when unbinding via SPOOL_ID=0
- Add unbind_spool_callback webhook endpoint for unbinding flow
- Add gcode.respond_info notifications for bind/unbind actions
- Add notification when RFID card is missing but spoolman is available
- Fix SPOOL_ID parsing to handle empty string values
Adds `24_settings_tweaks_spoolman.yaml` to enable/disable Spoolman via
firmware-config, prompting for the server URL on enable and validating
it is a reachable Spoolman instance before writing the moonraker config.

Extends firmware-config to support `inputs` on settings options: each
entry defines a named form field (label, placeholder, regex) rendered in
the confirm modal, validated client-side, and injected as named env vars
into the option `cmd`.
… RFID cards

- Move filament config methods from AFC_lane to AFC_lane_spoolman
- Auto-detect RFID cards and bind to Spoolman spools via lot_nr field
- Support comma-delimited card_uid values in lot_nr (card_uid:XXX,card_uid:YYY)
- Add SET_SPOOL_ID and REFRESH_SPOOL gcode commands per lane
- Implement webhook callbacks for Spoolman proxy integration
- Remove card_uid from other spools when binding to new spool
- Update afc-lite.md with comprehensive Spoolman auto-binding documentation
- Document RFID card detection flow and lot_nr format
- Add gcode commands reference (SET_SPOOL_ID, REFRESH_SPOOL)
- Add respond_info notifications for card binding/unbinding actions
- Update limitations section to reflect now-supported features
- Add automatic card_uid removal from spoolman when unbinding via SPOOL_ID=0
- Add unbind_spool_callback webhook endpoint for unbinding flow
- Add gcode.respond_info notifications for bind/unbind actions
- Add notification when RFID card is missing but spoolman is available
- Fix SPOOL_ID parsing to handle empty string values
paxx12 and others added 11 commits May 28, 2026 22:58
Adds `24_settings_tweaks_spoolman.yaml` to enable/disable Spoolman via
firmware-config, prompting for the server URL on enable and validating
it is a reachable Spoolman instance before writing the moonraker config.

Extends firmware-config to support `inputs` on settings options: each
entry defines a named form field (label, placeholder, regex) rendered in
the confirm modal, validated client-side, and injected as named env vars
into the option `cmd`.
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