Skip to content
This repository has been archived by the owner on Mar 14, 2023. It is now read-only.

JSON Decode Error #2

Open
Kuuchuu opened this issue Jun 21, 2021 · 1 comment
Open

JSON Decode Error #2

Kuuchuu opened this issue Jun 21, 2021 · 1 comment

Comments

@Kuuchuu
Copy link

Kuuchuu commented Jun 21, 2021

I set the script up to run on reboot to update a bunch of domains. It worked for a few of them, but most failed.
This is a snippet from my CRON log:

Subject: Cron <k****u@the-server> /bin/python3 /External/porkbun-dynamic-dns-python/porkbun-ddns.py /External/porkbun-dynamic-dns-python/config.json s*******k.cloud -i ${myip}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/k****u>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=k****u>
Message-Id: <[email protected]****h>
Date: Mon, 21 Jun 2021 00:22:04 -0500 (CDT)

Deleting existing A Record
Creating record: sudoz***k.cloud with answer of 67.***.***.217
Traceback (most recent call last):
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 50, in <module>
    print(createRecord()["status"])
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 28, in createRecord
    create = json.loads(requests.post(apiConfig["endpoint"] + '/dns/create/'+ rootDomain, data = json.dumps(createObj)).text)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

From k****[email protected]****h  Mon Jun 21 00:22:04 2021
Return-Path: <k****[email protected]****h>
X-Original-To: k****u
Delivered-To: k****[email protected]****h
Received: by the-server.T****h (Postfix, from userid 1000)
        id DBA18EC0AE; Mon, 21 Jun 2021 00:22:03 -0500 (CDT)
From: [email protected]****h (Cron Daemon)
To: k****[email protected]****h
Subject: Cron <k****u@the-server> /bin/python3 /External/porkbun-dynamic-dns-python/porkbun-ddns.py /External/porkbun-dynamic-dns-python/config.json z***k.download -i ${myip}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/k****u>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=k****u>
Message-Id: <[email protected]****h>
Date: Mon, 21 Jun 2021 00:22:03 -0500 (CDT)

Traceback (most recent call last):
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 47, in <module>
    myIP=getMyIP() #otherwise use the detected exterior IP address
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 14, in getMyIP
    ping = json.loads(requests.post(apiConfig["endpoint"] + '/ping/', data = json.dumps(apiConfig)).text)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

From k****[email protected]****h  Mon Jun 21 00:22:04 2021
Return-Path: <k****[email protected]****h>
X-Original-To: k****u
Delivered-To: k****[email protected]****h
Received: by the-server.T****h (Postfix, from userid 1000)
        id B2D57EC0AE; Mon, 21 Jun 2021 00:22:04 -0500 (CDT)
From: [email protected]****h (Cron Daemon)
To: k****[email protected]****h
Subject: Cron <k****u@the-server> /bin/python3 /External/porkbun-dynamic-dns-python/porkbun-ddns.py /External/porkbun-dynamic-dns-python/config.json z***k.family www -i ${myip}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/k****u>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=k****u>
Message-Id: <[email protected]****h>
Date: Mon, 21 Jun 2021 00:22:04 -0500 (CDT)

Deleting existing A Record
Creating record: www.z***k.family with answer of 67.***.***.217
Traceback (most recent call last):
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 50, in <module>
    print(createRecord()["status"])
  File "/External/porkbun-dynamic-dns-python/porkbun-ddns.py", line 28, in createRecord
    create = json.loads(requests.post(apiConfig["endpoint"] + '/dns/create/'+ rootDomain, data = json.dumps(createObj)).text)
  File "/usr/lib/python3.8/json/__init__.py", line 357, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.8/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.8/json/decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

From k****[email protected]****h  Mon Jun 21 00:22:04 2021
Return-Path: <k****[email protected]****h>
X-Original-To: k****u
Delivered-To: k****[email protected]****h
Received: by the-server.T****h (Postfix, from userid 1000)
        id B8883EC0AE; Mon, 21 Jun 2021 00:22:04 -0500 (CDT)
From: [email protected]****h (Cron Daemon)
To: k****[email protected]****h
Subject: Cron <k****u@the-server> myip="$(dig +short myip.opendns.com @resolver1.opendns.com)" && /bin/python3 /External/porkbun-dynamic-dns-python/porkbun-ddns.py /External/porkbun-dynamic-dns-python/config.json z***k.io -i ${myip}
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Cron-Env: <SHELL=/bin/sh>
X-Cron-Env: <HOME=/home/k****u>
X-Cron-Env: <PATH=/usr/bin:/bin>
X-Cron-Env: <LOGNAME=k****u>
Message-Id: <[email protected]****h>
Date: Mon, 21 Jun 2021 00:22:04 -0500 (CDT)

Deleting existing A Record
Creating record: z***k.io with answer of 67.***.***.217
SUCCESS

Thanks for making this, really appreciate it!

@rossporkbun
Copy link
Contributor

Hmm, I'm wondering if the API is throttling you due to doing a bunch of transactions in a row. I'll see if I can recreate and/or at least do some better error handling in here to make it more apparent what the issue is. This is one of my first Python projects, so I'm still getting used to doing proper error handling. Thanks for the thorough report.

con-f-use added a commit to con-f-use/porkbun-dynamic-dns-python that referenced this issue Dec 22, 2021
Modernizes the Python DDNS client:

* Use argparse for CLI argument handling (better help text, validation and error messages)
* Accept config file from stdin
* Use modern Python naming conventions
* Use ipaddress for validation
* Default value for the base url of the API
* Closes porkbundomains#2 
* Closes porkbundomains#3
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants