Skip to content

[Bug]: project.share #609

@faretek1

Description

@faretek1

scratchattach version

2.1.18

What happened?

I tried making a project, setting desc, and sharing it. It errored in the share part. I am using termux

Your code.

import scratchattach as sa

def main():
    sess = sa.login("faretek", "redacted")
    proj = sess.create_project(title="test btw")
    proj.set_instructions("i made this on my phone ig")
    proj.share()


if __name__ == "__main__":
    main()

Traceback

(sat) [u0_a189@localhost sat]$ uv run main.py
/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/scratchattach/site/session.py:1102: LoginDataWarning: IMPORTANT: If you included login credentials directly in your code (e.g. session_id, session_string, ...), then make sure to EITHER instead load them from environment variables or files OR remember to remove them before you share your code with anyone else. If you want to remove this warning, use `warnings.filterwarnings('ignore', category=scratchattach.LoginDataWarning)`
  warnings.warn(
Traceback (most recent call last):
  File "/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/requests/models.py", line 978, in json
    return complexjson.loads(self.text, **kwargs)
           ~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.13/json/__init__.py", line 352, in loads
    return _default_decoder.decode(s)
           ~~~~~~~~~~~~~~~~~~~~~~~^^^
  File "/data/data/com.termux/files/usr/lib/python3.13/json/decoder.py", line 345, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
  File "/data/data/com.termux/files/usr/lib/python3.13/json/decoder.py", line 363, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/data/com.termux/files/home/locode/sat/main.py", line 11, in <module>
    main()
    ~~~~^^
  File "/data/data/com.termux/files/home/locode/sat/main.py", line 7, in main
    proj.share()
    ~~~~~~~~~~^^
  File "/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/scratchattach/site/project.py", line 537, in share
    requests.put(
    ~~~~~~~~~~~~^
        f"https://api.scratch.mit.edu/proxy/projects/{self.id}/share/",
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        headers=self._json_headers,
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
        cookies=self._cookies,
        ^^^^^^^^^^^^^^^^^^^^^^
    )
    ^
  File "/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/scratchattach/utils/requests.py", line 97, in put
    self.check_response(r)
    ~~~~~~~~~~~~~~~~~~~^^^
  File "/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/scratchattach/utils/requests.py", line 53, in check_response
    if r.json() == {"code": "BadRequest", "message": ""}:
       ~~~~~~^^
  File "/data/data/com.termux/files/home/locode/sat/.venv/lib/python3.13/site-packages/requests/models.py", line 982, in json
    raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 2 column 1 (char 1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs triageNeed to apply low priority/high priority etcbugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions