flathub / flathub/org.texstudio.TeXstudio
gnome libraries return inconsistent data types leading to unmarshaling failures
- Dominant language
- Shell
- Stars
- 5
- Forks
- 15
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 1
Description
Here;s the debug output from attempting to install it on Ubuntu 24.04 with latest patches:
16:49 [DEBUG] Debug mode enabled
16:49 [DEBUG] Session type: wayland, Desktop: ubuntu:GNOME
16:49 [DEBUG] Connected to D-Bus session bus
16:49 [DEBUG] Received D-Bus response: {"title":"dlannom@miniv: ~/dev/git/rescuetime-linux-mutter","wm_class":"gnome-terminal-server","wm_class_instance":"gnome-terminal-server","pid":28380,"id":209478387,"width":1346,"height":805,"x":431,"y":1012,"focus":true,"in_current_workspace":true,"moveable":true,"resizeable":true,"canclose":true,"canmaximize":true,"maximized":0,"canminimize":true,"display":{},"frame_type":0,"window_type":0,"layer":2,"monitor":1,"role":null,"area":{},"area_all":{},"area_cust":{}}
16:49 [ERROR] Failed to connect to GNOME Shell FocusedWindow extension: failed to parse window JSON: json: cannot unmarshal number into Go struct field MutterWindow.maximized of type bool
Looking at the extension it seems to be consistent on how it request the data suggesting the problem is variable in the libraries.
Since I'm not that familiar with go I ask an AI qwen model to suggest a fix which it suggested as wrapper around bool type
// Add this near your MutterWindow struct definition
type FlexibleBool bool
func (fb *FlexibleBool) UnmarshalJSON(data []byte) error {
// Try parsing as boolean first
var b bool
if err := json.Unmarshal(data, &b); err == nil {
*fb = FlexibleBool(b)
return nil
}
// Fallback to integer (0 = false, non-zero = true)
var n int
if err := json.Unmarshal(data, &n); err != nil {
return fmt.Errorf("cannot unmarshal %s into FlexibleBool", string(data))
}
*fb = FlexibleBool(n != 0)
return nil
}
// Update the struct field:
type MutterWindow struct {
// ... other fields ...
Maximized FlexibleBool `json:"maximized"`
// ...
}
I've tested this in internal/common/dbus.go though I also had to import json and fmt. It seems to work fine with limited testing
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in internal/common/dbus.go and inspect the MutterWindow unmarshaling path for the maximized field. Reproduce the GNOME FocusedWindow extension response shown in the issue, including its numeric value, and verify that supported boolean and numeric data types no longer cause parsing to fail. Done means the GNOME Shell connection succeeds without the reported unmarshaling error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 72/100