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

[BUG] JSON syntax error on refresh #257

Open
ask6483 opened this issue Dec 30, 2024 · 16 comments
Open

[BUG] JSON syntax error on refresh #257

ask6483 opened this issue Dec 30, 2024 · 16 comments
Labels

Comments

@ask6483
Copy link

ask6483 commented Dec 30, 2024

Describe the bug
There is JSON error on refresh.

Screenshots
image

To Reproduce
Steps to reproduce the behavior:

  1. Click on 'Refresh Now'
  2. See error in notification popup

Desktop (please complete the following information):

  • OS: Debian Trixie
  • Extension Version: 50
  • GNOME Version: 47.2
@ask6483 ask6483 added the bug label Dec 30, 2024
@ask6483 ask6483 changed the title [BUG] [BUG] JSON syntax error on refresh Dec 30, 2024
@ask6483
Copy link
Author

ask6483 commented Dec 30, 2024

Journald debug log output:

gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: next check in 86400 seconds
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: Recieved 0 bytes
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: _parseData() failed with error SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data @ 802
gru 30 12:36:37 mimas gnome-shell[3231]: error: BingWallpaper extension error: Bing metadata parsing error check SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data @ 802
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: _parseData@file:///home/ask/.local/share/gnome-shell/extensions/[email protected]/extension.js:802:31
                                         _processMessageRefresh@file:///home/ask/.local/share/gnome-shell/extensions/[email protected]/extension.js:738:18
                                         _refresh/<@file:///home/ask/.local/share/gnome-shell/extensions/[email protected]/extension.js:704:26
                                         @resource:///org/gnome/shell/ui/init.js:21:20
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: /th?id=OHR.LakeBledSnow_EN-US5836531079
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: key selected-image set to LakeBledSnow_EN-US5836531079 (returned true)
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: scale factor: 1
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: image set to : /home/ask/.cache/bingwc/20241227-LakeBledSnow_EN-US5836531079_1920x1080.jpg
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: Storing state as JSON: {"maxlongdate":202412270800,"title":"Lake Bled, Slovenia","explanation":"Bing Wallpaper of the Day for 2024-12-27","copyright":"© Kesu01/Getty Images","longstartdate":"202412270800","imageinfolink":"https://www.bing.com/search?q=Lake+Bled+Slovenia&form=hpcapt&filters=HpDate%3a%2220241227_0800%22","imageURL":"https://www.bing.com/th?id=OHR.LakeBledSnow_EN-US5836531079_1920x1080.jpg&qlt=100","filename":"/home/ask/.cache/bingwc/20241227-LakeBledSnow_EN-US5836531079_1920x1080.jpg","favourite":false,"width":1920,"height":1080,"shuffledue":0}
gru 30 12:36:37 mimas gnome-shell[3231]: BingWallpaper extension: key state set to {"maxlongdate":202412270800,"title":"Lake Bled, Slovenia","explanation":"Bing Wallpaper of the Day for 2024-12-27","copyright":"© Kesu01/Getty Images","longstartdate":"202412270800","imageinfolink":"https://www.bing.com/search?q=Lake+Bled+Slovenia&form=hpcapt&filters=HpDate%3a%2220241227_0800%22","imageURL":"https://www.bing.com/th?id=OHR.LakeBledSnow_EN-US5836531079_1920x1080.jpg&qlt=100","filename":"/home/ask/.cache/bingwc/20241227-LakeBledSnow_EN-US5836531079_1920x1080.jpg","favourite":false,"width":1920,"height":1080,"shuffledue":0} (returned true)

@proninyaroslav
Copy link

Same problem: #248 (comment)

I got the same error in another similar app for Android, but enabling VPN helped me. In the case of the extension, I could not connect it via VPN, it seems the extension doesn't accept the system proxy settings.

@proninyaroslav
Copy link

It seems I was mistaken about VPN. I tried to figure out why the code was giving an error. And I placed log messages in the code. And I noticed that a delay of 1-2 seconds (setTimeout) before processing the HTTP response allows the code to work without errors:

_processMessageRefresh(message) {
      setTimeout(() => {
        const decoder = new TextDecoder()
        try {
          let data =
            Soup.MAJOR_VERSION >= 3
              ? decoder.decode(
                  this.httpSession.send_and_read_finish(message).get_data()
                ) // Soup3
              : message.response_body.data // Soup 2

          log("Recieved " + data.length + " bytes")
          this._parseData(data)

          if (!this._settings.get_boolean("random-mode-enabled"))
            this._selectImage()
        } catch (error) {
          log("Network error occured: " + error)
          notifyError("network error occured\n" + error)
          this._updatePending = false
          this._restartTimeout(TIMEOUT_SECONDS_ON_HTTP_ERROR)
        }
      }, 2000)
    }

Location in the code:

_processMessageRefresh(message) {

Now it updates wallpapers without any errors.

@Gohan61
Copy link

Gohan61 commented Dec 30, 2024

I managed to successfully refresh now without any issues and downloading the image of today. I don't know what the issue was but if a timeout fixed the issue for you @proninyaroslav , maybe some race condition was happening?

@proninyaroslav
Copy link

UPD: after some time this problem came back. It seems to be a floating problem.

@neffo
Copy link
Owner

neffo commented Dec 30, 2024

On occasions the API will be down, it should keep trying (and it can catch up to get the missed images).

If you don't mind, can you say which countries you are in? (One option might be to select a different market in the settings like English rest of world, etc.)

Does opening the link to the API end point give any error messages?

@Gohan61
Copy link

Gohan61 commented Dec 30, 2024

UPD: after some time this problem came back. It seems to be a floating problem.

You're right, just like 10 minutes later refreshing brings back the problem

@proninyaroslav
Copy link

proninyaroslav commented Dec 30, 2024

@neffo
The endpoint URL returns me HTTP 200, but empty:
image

@neffo
Copy link
Owner

neffo commented Dec 30, 2024

Hmm, you should get something like this JSON if it works:

{
  "market": {
    "mkt": "en-US"
  },
  "images": [
    {
      "startdate": "20241230",
      "fullstartdate": "202412300800",
      "enddate": "20241231",
      "url": "/th?id=OHR.MountFieldNP_EN-US6905459745_1920x1080.jpg&rf=LaDigue_1920x1080.jpg&pid=hp",
      "urlbase": "/th?id=OHR.MountFieldNP_EN-US6905459745",
      "copyright": "Tasmanian snow gum and pandani plants near Lake Dobson, Mount Field National Park, Tasmania, Australia (© Whitworth Images/Getty Images)",
      "copyrightlink": "https://www.bing.com/search?q=Mount+Field+National+Park&form=hpcapt&filters=HpDate%3a%2220241230_0800%22",
      "title": "A park for all seasons",
      "quiz": "/search?q=Bing+homepage+quiz&filters=WQOskey:%22HPQuiz_20241230_MountFieldNP%22&FORM=HPQUIZ",
      "wp": true,
      "hsh": "025b455261fb11b6bd7b3494d52708ae",
      "drk": 1,
      "top": 1,
      "bot": 1,
      "hs": []
    }
  ],
  "tooltips": {
    "loading": "Loading...",
    "previous": "Previous image",
    "next": "Next image",
    "walle": "This image is not available to download as wallpaper.",
    "walls": "Download this image. Use of this image is restricted to wallpaper only."
  }
}

@proninyaroslav
Copy link

One option might be to select a different market in the settings like English rest of world, etc.

It seems that this cannot be changed in the extension settings. At least I didn't find it.

@proninyaroslav
Copy link

Hmm, you should get something like this JSON if it works:

After some attempt to refresh the page it gave me JSON. But once.

@neffo
Copy link
Owner

neffo commented Dec 30, 2024

One option might be to select a different market in the settings like English rest of world, etc.

It seems that this cannot be changed in the extension settings. At least I didn't find it.

Yeah it's a hidden setting now, you can set the 'market' to something like 'EN-ROW' and you might have some more luck. Probably unlikely, as it's hitting the same end point not a different server.

@AxelMKlein
Copy link

AxelMKlein commented Dec 30, 2024

Hi,
I'm also affected by this issue. Ubuntu 24.04, Gnome version 46, Extension version 50 here.
Anything I can do to help debugging?

Best regards
Axel

@proninyaroslav
Copy link

proninyaroslav commented Dec 30, 2024

My guess is that something is broken in the API. I even tried Tor to exclude any blocking (from any side), but it just returns an empty result, with rare exceptions.
Also, you can go to bing.com and you can see the wallpaper, it doesn't look like a block.

@proninyaroslav
Copy link

proninyaroslav commented Dec 30, 2024

How my response looks like:

HTTP/1.1 200 OK
Content-Length: 0
Cache-Control: private
Content-Encoding: gzip
Vary: Accept-Encoding
X-EventID: 6772e182e20a44ca8054b34dafa00a45
UserAgentReductionOptOut: A7kgTC5xdZ2WIVGZEfb1hUoNuvjzOZX3VIV/BA6C18kQOOF50Q0D3oWoAm49k3BQImkujKILc7JmPysWk3CSjwUAAACMeyJvcmlnaW4iOiJodHRwczovL3d3dy5iaW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiU2VuZEZ1bGxVc2VyQWdlbnRBZnRlclJlZHVjdGlvbiIsImV4cGlyeSI6MTY4NDg4NjM5OSwiaXNTdWJkb21haW4iOnRydWUsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0=
Date: Mon, 30 Dec 2024 18:08:02 GMT
Connection: close
Alt-Svc: h3=":443"; ma=93600
X-CDN-TraceID: 0.1b171002.1735582082.4a7bfce


And how looks a successfull response (after 5-6 times of continuous refresh):

HTTP/1.1 200 OK
Content-Length: 798
Content-Type: application/json; charset=utf-8
Cache-Control: private
Content-Encoding: gzip
Vary: Accept-Encoding
X-EventID: 6772e40d5d7146afbf1c3e8c214e3767
UserAgentReductionOptOut: A7kgTC5xdZ2WIVGZEfb1hUoNuvjzOZX3VIV/BA6C18kQOOF50Q0D3oWoAm49k3BQImkujKILc7JmPysWk3CSjwUAAACMeyJvcmlnaW4iOiJodHRwczovL3d3dy5iaW5nLmNvbTo0NDMiLCJmZWF0dXJlIjoiU2VuZEZ1bGxVc2VyQWdlbnRBZnRlclJlZHVjdGlvbiIsImV4cGlyeSI6MTY4NDg4NjM5OSwiaXNTdWJkb21haW4iOnRydWUsImlzVGhpcmRQYXJ0eSI6dHJ1ZX0=
Content-Security-Policy: script-src https: 'strict-dynamic' 'report-sample' 'wasm-unsafe-eval' 'nonce-s7uylc/vj3X/yXBSp2Q8Fpn/zUSGZ0BxiwQc53uiEvo='; base-uri 'self';
P3P: CP="NON UNI COM NAV STA LOC CURa DEVa PSAa PSDa OUR IND"
Date: Mon, 30 Dec 2024 18:18:53 GMT
Connection: close
Alt-Svc: h3=":443"; ma=93600
X-CDN-TraceID: 0.0a171002.1735582733.19d1d88d

{
  "images": [
    {
      "startdate": "20241230",
      "fullstartdate": "202412300800",
      "enddate": "20241231",
...

@proninyaroslav
Copy link

It seems like the API is working fine today. Updates are happening without an empty response.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants