Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON Error #117

Open
na7q opened this issue Sep 8, 2024 · 5 comments
Open

JSON Error #117

na7q opened this issue Sep 8, 2024 · 5 comments
Labels
bug Something isn't working

Comments

@na7q
Copy link

na7q commented Sep 8, 2024

Describe the bug
JSON errors prevents getting and clearing alerts.

To Reproduce
Steps to reproduce the behavior:
Improperly format the data.json file to reproduce.

Expected behavior
Errors within the json should either delete or ignore, varying by error reason, and continue with getting alerts, or clearing.

Files

  • SkywarnPlus Files:
    • /tmp/SkywarnPlus/data.json
    • SkyDescribe.py
    • SkywarnPlus.py

Screenshots
N/A

Node (please complete the following information):

  • OS: [HAMVOIP Latest]

Additional context
This was noticed after days of alerts that were no longer active for the counties. It was noticed by trying to run skydescribe and returned an error.

Unfortunately the json file was removed as I was testing, and didn't manage to keep the invalid formatted one. There was a line in the description that caused it to be in correctly formatted.

Example of the format noticed in description. It was missing the outer quote.
"description": "This alert was manually injected as a test.,

[root@AllStar-Node SkywarnPlus]# python3 SkyDescribe.py 1
Traceback (most recent call last):
  File "SkyDescribe.py", line 367, in <module>
    main(sys.argv[1])
  File "SkyDescribe.py", line 271, in main
    state = load_state()
  File "SkyDescribe.py", line 98, in load_state
    state = json.load(file)
  File "/usr/lib/python3.5/json/__init__.py", line 268, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Invalid control character at: line 102 column 640 (char 8748)
@na7q na7q added the bug Something isn't working label Sep 8, 2024
@mjwgeek
Copy link

mjwgeek commented Oct 26, 2024

I'm using the latest version and I have not encountered this "bug" that you speak of. Perhaps it was self induced?

@na7q
Copy link
Author

na7q commented Oct 26, 2024

Here's an example of some of the JSON formatting problems within this. No idea of the cause as of yet. Note the "}: null," part. Where the error is, seems to vary by the alerts.

{
    "last_alerts": [
        [
            "High Wind Warning",
            [
                {
                    "severity": 3,
                    "description": "* WHAT...South winds 25 to 35 mph with gusts up to 60 mph expected\nat beaches and headlands. Gusts up to 45 mph for inland\ncommunities.\n\n* WHERE...Clatsop County and Tillamook County Coast, and South\nWashington Coast.\n\n* WHEN...From 7 PM this evening to 2 AM PDT Saturday.\n\n* IMPACTS...Damaging winds will blow down trees and power lines.\nWidespread power outages are expected. Travel will be difficult,\nespecially for high profile vehicles.\n\n* ADDITIONAL DETAILS...This is the first system of the season with\nwinds this strong and could cause power outages and minor damage\nalong the beaches and headlands. Similar systems later in the fall\nand winter seasons may not be as impactful.",
                    "end_time_utc": "2024-10-26T09:00:00.000000Z",
                    "county_code": "ORC007"
                },
                {
                    "severity": 3,
                    "description": "* WHAT...South winds 25 to 35 mph with gusts up to 60 mph expected\nat beaches and headlands. Gusts up to 45 mph for inland\ncommunities.\n\n* WHERE...Clatsop County and Tillamook County Coast, and South\nWashington Coast.\n\n* WHEN...From 7 PM this evening to 2 AM PDT Saturday.\n\n* IMPACTS...Damaging winds will blow down trees and power lines.\nWidespread power outages are expected. Travel will be difficult,\nespecially for high profile vehicles.\n\n* ADDITIONAL DETAILS...This is the first system of the season with\nwinds this strong and could cause power outages and minor damage\nalong the beaches and headlands. Similar systems later in the fall\nand winter seasons may not be as impactful.",
                    "end_time_utc": "2024-10-26T09:00:00.000000Z",
                    "county_code": "WAC049"
                }
            ]
        ]
    ],
    "last_sayalert": [],
    "id": null,
    "alertscript_alerts": [],
    "active_alerts": [],
    "ct": null
}: null,
    "active_alerts": []
}

@na7q
Copy link
Author

na7q commented Oct 26, 2024

Another alert with exact issue.

{
    "alertscript_alerts": [],
    "active_alerts": [],
    "last_sayalert": [],
    "id": null,
    "last_alerts": [
        [
            "Frost Advisory",
            [
                {
                    "county_code": "WAC059",
                    "end_time_utc": "2024-10-23T15:00:00.000000Z",
                    "severity": 1,
                    "description": "* WHAT...Temperatures as low as 35 degrees, locally as low as 32\ndegrees, will result in frost formation.\n\n* WHERE...In Oregon, North Oregon Coast Range, North Oregon Coast\nRange Lowlands, and Upper Hood River Valley. In Washington, South\nWashington Cascade Foothills.\n\n* WHEN...For the first Frost Advisory, from midnight tonight to 8 AM\nPDT Wednesday. For the second Frost Advisory, from midnight\nWednesday Night to 8 AM PDT Thursday.\n\n* IMPACTS...Frost could harm sensitive outdoor vegetation. Sensitive\noutdoor plants may be killed if left uncovered."
                },
                {
                    "county_code": "ORC007",
                    "end_time_utc": "2024-10-23T15:00:00.000000Z",
                    "severity": 1,
                    "description": "* WHAT...Temperatures as low as 35 degrees, locally as low as 32\ndegrees, will result in frost formation.\n\n* WHERE...In Oregon, North Oregon Coast Range, North Oregon Coast\nRange Lowlands, and Upper Hood River Valley. In Washington, South\nWashington Cascade Foothills.\n\n* WHEN...For the first Frost Advisory, from midnight tonight to 8 AM\nPDT Wednesday. For the second Frost Advisory, from midnight\nWednesday Night to 8 AM PDT Thursday.\n\n* IMPACTS...Frost could harm sensitive outdoor vegetation. Sensitive\noutdoor plants may be killed if left uncovered."
                }
            ]
        ]
    ],
    "ct": null
}           ]
        ]
    ]
}

@na7q
Copy link
Author

na7q commented Oct 26, 2024

I'm using the latest version and I have not encountered this "bug" that you speak of. Perhaps it was self induced?

Self induced by the script. I will try to look over the script and see where the problem is.

@na7q
Copy link
Author

na7q commented Oct 26, 2024

na7q@97c7a7c

Made some updates to it. This recognizes the improper formatting of JSON files. Resets to default. Good temp fix until I get some time to look at it more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants