[PR #1107] [CLOSED] fix(spoolman): stop syncing third-party spools via synthetic AMS tag_uid #1161

Closed
opened 2026-05-06 12:35:26 +02:00 by BreizhHardware · 0 comments

📋 Pull Request Information

Original PR: https://github.com/maziggy/bambuddy/pull/1107
Author: @netscout2001
Created: 4/23/2026
Status: Closed

Base: devHead: fix/spoolman-synthetic-uid-detection


📝 Commits (2)

  • 4b21e02 fix(spoolman): reject synthetic AMS tag_uid as Bambu Lab spool indicator
  • d8d52a0 Merge branch 'dev' into fix/spoolman-synthetic-uid-detection

📊 Changes

4 files changed (+52 additions, -57 deletions)

View changed files

📝 backend/app/api/routes/spoolman.py (+8 -16)
📝 backend/app/services/spoolman.py (+10 -21)
📝 backend/tests/unit/services/test_spoolman_service.py (+31 -8)
📝 frontend/src/pages/PrintersPage.tsx (+3 -12)

📄 Description

Description

Bambu printer firmware synthesises a 16-char tag_uid value
(serial_hash[4B] + slot[4B]) for every AMS slot that contains a spool
without an NFC chip. The previous is_bambu_lab_spool() fallback
accepted any non-zero 16-char hex tag_uid as evidence of a Bambu Lab
RFID tag, causing third-party spools (SUNLU, Polymaker, etc.) to be
auto-created in Spoolman with the synthetic UID written into extra.tag.

Only tray_uuid (32-char hex, read from the real NFC chip) is a reliable
indicator. The tag_uid fallback is removed entirely.

Note for existing installations: Spoolman spools that were
incorrectly created from synthetic UIDs before this fix are not
cleaned up automatically
. They must be deleted manually in Spoolman.
Affected entries can be identified by a 16-char value in their
extra.tag field (e.g. 6319B70A00000001).

Fixes #1068

Documentation

  • Docs PR(s) linked above
  • No docs update required — reason: internal sync logic fix, no
    user-visible config or API change

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Test addition or update

Changes Made

  • services/spoolman.py — remove tag_uid (16-char) fallback from
    is_bambu_lab_spool(); tag_uid and tray_info_idx params kept for
    API compatibility but are now ignored; docstring updated
  • api/routes/spoolman.py — simplify two current_tray_uuids tracking
    blocks that became dead code after the gate change (both after the
    is_bambu_lab_spool() guard, so tray_uuid is always present)
  • frontend/src/pages/PrintersPage.tsx — align isBambuLabSpool() with
    backend: check only tray_uuid, drop the tag_uid branch that was
    showing third-party spools as "Bambu Lab" in the AMS vendor label
  • tests/unit/services/test_spoolman_service.py — flip
    test_valid_tag_uid_returns_truetest_synthetic_ams_uid_returns_false;
    add SUNLU exact UIDs from issue report (6319B70A0000000{0-3}),
    tag_uid + preset combo case, and NTAG215 (14-char) edge case

Testing

  • I have tested this on my local machine
  • All 33 unit tests in TestIsBambuLabSpool / TestSpoolmanClient pass
  • All 35 integration tests in test_spoolman_api.py pass
  • All 189 unit tests across remaining spoolman test files pass
  • ruff check + ruff format clean
  • TypeScript build (tsc -b && vite build) clean

Additional Notes

The tag_uid fallback was introduced in upstream commit f9b47282
("BL spool detection fix") with the intent to handle RFID readers that
return shorter UIDs. In practice, Bambu Lab NFC chips always produce a
32-char tray_uuid; the 16-char value is only ever the firmware-generated
synthetic identifier for chipless spools. The fix closes the false-positive
path without affecting any legitimate Bambu Lab spool detection.

link_spool (manual user linking) and the SpoolBuddy NFC write-result
path are not affected — both accept tags of any valid length as
explicit user actions.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/maziggy/bambuddy/pull/1107 **Author:** [@netscout2001](https://github.com/netscout2001) **Created:** 4/23/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `fix/spoolman-synthetic-uid-detection` --- ### 📝 Commits (2) - [`4b21e02`](https://github.com/maziggy/bambuddy/commit/4b21e02a7927eb6474b43fa6ab335c2f57367cbc) fix(spoolman): reject synthetic AMS tag_uid as Bambu Lab spool indicator - [`d8d52a0`](https://github.com/maziggy/bambuddy/commit/d8d52a0d4ac1a50ae643eee1b89b513241d581a4) Merge branch 'dev' into fix/spoolman-synthetic-uid-detection ### 📊 Changes **4 files changed** (+52 additions, -57 deletions) <details> <summary>View changed files</summary> 📝 `backend/app/api/routes/spoolman.py` (+8 -16) 📝 `backend/app/services/spoolman.py` (+10 -21) 📝 `backend/tests/unit/services/test_spoolman_service.py` (+31 -8) 📝 `frontend/src/pages/PrintersPage.tsx` (+3 -12) </details> ### 📄 Description ## Description Bambu printer firmware synthesises a 16-char `tag_uid` value (`serial_hash[4B] + slot[4B]`) for every AMS slot that contains a spool **without** an NFC chip. The previous `is_bambu_lab_spool()` fallback accepted any non-zero 16-char hex `tag_uid` as evidence of a Bambu Lab RFID tag, causing third-party spools (SUNLU, Polymaker, etc.) to be auto-created in Spoolman with the synthetic UID written into `extra.tag`. Only `tray_uuid` (32-char hex, read from the real NFC chip) is a reliable indicator. The `tag_uid` fallback is removed entirely. > **Note for existing installations:** Spoolman spools that were > incorrectly created from synthetic UIDs before this fix are **not > cleaned up automatically**. They must be deleted manually in Spoolman. > Affected entries can be identified by a 16-char value in their > `extra.tag` field (e.g. `6319B70A00000001`). ## Related Issue Fixes #1068 ## Documentation - [ ] Docs PR(s) linked above - [x] No docs update required — reason: internal sync logic fix, no user-visible config or API change ## Type of Change - [x] Bug fix (non-breaking change that fixes an issue) - [x] Test addition or update ## Changes Made - `services/spoolman.py` — remove `tag_uid` (16-char) fallback from `is_bambu_lab_spool()`; `tag_uid` and `tray_info_idx` params kept for API compatibility but are now ignored; docstring updated - `api/routes/spoolman.py` — simplify two `current_tray_uuids` tracking blocks that became dead code after the gate change (both after the `is_bambu_lab_spool()` guard, so `tray_uuid` is always present) - `frontend/src/pages/PrintersPage.tsx` — align `isBambuLabSpool()` with backend: check only `tray_uuid`, drop the `tag_uid` branch that was showing third-party spools as "Bambu Lab" in the AMS vendor label - `tests/unit/services/test_spoolman_service.py` — flip `test_valid_tag_uid_returns_true` → `test_synthetic_ams_uid_returns_false`; add SUNLU exact UIDs from issue report (`6319B70A0000000{0-3}`), `tag_uid` + preset combo case, and NTAG215 (14-char) edge case ## Testing - [x] I have tested this on my local machine - All 33 unit tests in `TestIsBambuLabSpool` / `TestSpoolmanClient` pass - All 35 integration tests in `test_spoolman_api.py` pass - All 189 unit tests across remaining spoolman test files pass - `ruff check` + `ruff format` clean - TypeScript build (`tsc -b && vite build`) clean ## Additional Notes The `tag_uid` fallback was introduced in upstream commit `f9b47282` ("BL spool detection fix") with the intent to handle RFID readers that return shorter UIDs. In practice, Bambu Lab NFC chips always produce a 32-char `tray_uuid`; the 16-char value is only ever the firmware-generated synthetic identifier for chipless spools. The fix closes the false-positive path without affecting any legitimate Bambu Lab spool detection. `link_spool` (manual user linking) and the SpoolBuddy NFC write-result path are **not** affected — both accept tags of any valid length as explicit user actions. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
BreizhHardware 2026-05-06 12:35:26 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/bambuddy#1161
No description provided.