Skip to content
This repository was archived by the owner on Jul 31, 2026. It is now read-only.

Commit ea70033

Browse files
fix(firebase): signInWithPassword — DynamicJsonDocument(1792) + filter replaces StaticJsonDocument<768>
Firebase JWT response is ~2KB; the 768-byte static doc caused silent parse failure on every email/password sign-in. Now only idToken, refreshToken and localId are parsed (filter), so memory usage stays minimal while handling the full response. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 339a675 commit ea70033

1 file changed

Lines changed: 23 additions & 16 deletions

File tree

‎src/main.cpp‎

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,19 @@
1717
// §8 CLOUD PARSING 469– 483
1818
// §9 WIFI SETUP 484– 742
1919
// §10 LITTLEFS 743– 787
20-
// §11 FIREBASE AUTHENTICATION 788– 966
21-
// §12 FIRESTORE SCALE HEARTBEAT & SYNC 967– 1894
22-
// §13 WEBSOCKET 1895– 1931
23-
// §14 WEIGHT FILTER HELPERS 1932– 1946
24-
// §15 POST-SEND STATE RESET (shared by all send paths) 1947– 1968
25-
// §16 SHARED WEIGHT PUSH HANDLER (used by /api/weight and /api/push-weight) 1969– 2041
26-
// §17 WEB SERVER 2042– 2593
27-
// §18 CLOUD COMMUNICATION 2594– 2867
28-
// §19 mDNS 2868– 2905
29-
// §20 SCALE 2906– 2997
30-
// §21 RFID 2998– 3376
31-
// §22 OTA — Over-the-air firmware + filesystem update 3377– 3745
32-
// §23 SETUP & LOOP 3746– 4079
20+
// §11 FIREBASE AUTHENTICATION 788– 973
21+
// §12 FIRESTORE SCALE HEARTBEAT & SYNC 974– 1901
22+
// §13 WEBSOCKET 1902– 1938
23+
// §14 WEIGHT FILTER HELPERS 1939– 1953
24+
// §15 POST-SEND STATE RESET (shared by all send paths) 1954– 1975
25+
// §16 SHARED WEIGHT PUSH HANDLER (used by /api/weight and /api/push-weight) 1976– 2048
26+
// §17 WEB SERVER 2049– 2600
27+
// §18 CLOUD COMMUNICATION 2601– 2874
28+
// §19 mDNS 2875– 2912
29+
// §20 SCALE 2913– 3004
30+
// §21 RFID 3005– 3383
31+
// §22 OTA — Over-the-air firmware + filesystem update 3384– 3752
32+
// §23 SETUP & LOOP 3753– 4086
3333
//
3434
// To regenerate this block: ./scripts/update_toc.sh
3535
// ─── TOC END ───────────────────────────────────────────────
@@ -821,9 +821,16 @@ bool firebaseSignIn() {
821821
firebaseAuth = false;
822822
return false;
823823
}
824-
StaticJsonDocument<768> doc;
825-
if (deserializeJson(doc, resp)) {
826-
Serial.println("[FIREBASE] SignIn JSON parse error");
824+
// Firebase JWT response is ~2 KB — use a filter to parse only the 3 fields we need
825+
// (StaticJsonDocument<768> was too small and caused silent parse failure)
826+
StaticJsonDocument<64> filter;
827+
filter["idToken"] = true;
828+
filter["refreshToken"] = true;
829+
filter["localId"] = true;
830+
DynamicJsonDocument doc(1792);
831+
DeserializationError err = deserializeJson(doc, resp, DeserializationOption::Filter(filter));
832+
if (err) {
833+
Serial.printf("[FIREBASE] SignIn JSON parse error: %s\n", err.c_str());
827834
firebaseAuth = false;
828835
return false;
829836
}

0 commit comments

Comments
 (0)