fix: prevent crash on corrupted interface in edit dialog#710
Merged
torlando-tech merged 1 commit intomainfrom Mar 25, 2026
Merged
Conversation
…interface Fixes #693 — entityToConfig throws IllegalArgumentException for unknown interface types, but showEditDialog was the only caller without a try-catch. A corrupted type field in the database (e.g. invisible unicode characters) would crash the app on tap. Now shows an error message instead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Greptile SummaryThis PR closes a crash bug (#693) by wrapping Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant UI as UI / Composable
participant VM as InterfaceManagementViewModel
participant Repo as InterfaceRepository
participant DB as Room DB
UI->>VM: showEditDialog(interfaceEntity)
alt Happy path (valid entity)
VM->>Repo: entityToConfig(entity)
Repo->>DB: lookup type field
DB-->>Repo: valid type string
Repo-->>VM: InterfaceConfig (typed)
VM->>VM: _configState.value = entityToConfigState(...)
VM->>VM: _state.value.copy(showAddDialog=true, editingInterface=entity)
VM-->>UI: dialog opens
else Corrupted entity (e.g. bad `type` field) — NEW behaviour
VM->>Repo: entityToConfig(entity)
Repo-->>VM: throws IllegalArgumentException
VM->>VM: Log.e(TAG, ...)
VM->>VM: showError("Failed to load interface: …")
VM->>VM: _state.value.copy(errorMessage=…)
VM-->>UI: error toast / snackbar shown, dialog stays closed
end
Reviews (1): Last reviewed commit: "fix: catch exception in showEditDialog t..." | Re-trigger Greptile |
Contributor
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
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
showEditDialog()was the onlyentityToConfig()caller without a try-catchtypefield in the Room database (e.g. invisible unicode characters) causedIllegalArgumentExceptionto crash the app when the user tapped an interface to edit itTest plan
InterfaceManagementViewModeltests pass (121 tasks, BUILD SUCCESSFUL)typefield and verify tapping it shows an error toast instead of crashing🤖 Generated with Claude Code