fix: alarm comment crash and wrong display format#236
Merged
deaflynx merged 2 commits intothingsboard:masterfrom Apr 27, 2026
Merged
fix: alarm comment crash and wrong display format#236deaflynx merged 2 commits intothingsboard:masterfrom
deaflynx merged 2 commits intothingsboard:masterfrom
Conversation
The API expects comment as a JSON object {text: ...} but the mobile app
was sending raw strings, causing NoSuchMethodError on .edited/.text
access. Normalize comment field in datasource for both Map and legacy
String formats.
Comment parsing (Map/String → AlarmCommentJsonNode) is now handled in thingsboard_client's AlarmComment.fromJson, so the datasource becomes a clean pass-through again.
vvlladd28
approved these changes
Apr 27, 2026
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.
Summary
Fixes a crash when viewing alarm comments and a display issue where system activity entries (assignments, status changes) were rendered as raw JSON
{text: ..., subtype: ..., userName: ...}instead of the actual message.Root cause
The ThingsBoard API expects the alarm comment payload as a JSON object (
{"text": "..."}), but the mobile app was posting comments as plainStringvalues. The server tolerates both formats on write, but returns whatever was stored:MapStringAlarmComment.commentis typed asdynamicin the client library, so widgets calling.edited/ accessing the full text assumed a typed object and crashed withNoSuchMethodError: Class 'String' has no instance getter 'edited'whenever they encountered a legacy mobile comment. System activity widgets calledtoString()on the map, producing the raw{text: ..., subtype: ...}output.Changes
Flutter app (
flutter_thingsboard_app)alarm_details_datasource.dart— post/update now send the API-expected{'text': comment}payload instead of a raw string. Removed_parseCommentworkaround since parsing is now handled in the client library.user_comment_widget.dart,system_activity_widget.dart,alarm_edit_comment_textfield.dart) — use(comment as AlarmCommentJsonNode).text/.editedinstead ofdynamicaccess.Dart client library (
thingsboard_client)AlarmComment.fromJson— parsescommentfield intoAlarmCommentJsonNodeautomatically (handles bothMapand legacyStringformats).AlarmComment.toJson— serializesAlarmCommentJsonNodeback to a Map for the API.Test plan