docat icon indicating copy to clipboard operation
docat copied to clipboard

404 errors with every upload

Open flacomalone opened this issue 1 year ago • 5 comments

I keep on being shown 404 errors in the UI when I upload new projects.

I am using docker version 1.5.2. UI looks all good, but when I use the project uploaded via UI, or docatl, nothing seems to be inserted successfully, or at least it cannot be shown.

I tried uploading the following items converted to .zip

  • single index.html file
  • complete sphinxs output directory
  • pdf file
  • example directory under /docs in DOCATL repo

None of them seem to be able to be rendered after the upload.

flacomalone avatar Dec 09 '24 11:12 flacomalone

Can you share an example of what you upload?

fliiiix avatar Dec 09 '24 16:12 fliiiix

reopen when applicable

fliiiix avatar Apr 03 '25 17:04 fliiiix

I ran into this same problem, and it was driving me crazy. The website upload would work but not the scripted one using requests.

The root cause was whitespace at the end of the version. In the image, one of the 0.1.0 was uploaded with \n at the end. Image

bmarroquin avatar Apr 08 '25 22:04 bmarroquin

Here is the code that was causing the problem if you want to try it

from pathlib import Path
from zipfile import ZIP_DEFLATED, ZipFile

import requests

cwd = Path.cwd()
docs_dirs = cwd / "build"
zip_path = cwd / "docs.zip"

with ZipFile(zip_path, "w", ZIP_DEFLATED) as zip_file:
    for item in docs_dirs.rglob("*"):
        relative_name = item.relative_to(docs_dirs)
        zip_file.write(item, arcname=relative_name)

# this is broken, results in a 404 while trying to access the documentation.
version = subprocess.run(["poetry", "version", "-s"], check=True, capture_output=True, text=True).stdout
# This fixes the issue
# version = subprocess.run(["poetry", "version", "-s"], check=True, capture_output=True, text=True).stdout.strip()

project_url = f"https://..../api/test_projct/{version}"
with zip_path.open("rb") as zip_file:
    response = requests.post(project_url, files={"file": zip_file})
response.raise_for_status()

bmarroquin avatar Apr 08 '25 22:04 bmarroquin

Fair enough i guess we could restrict whitespace characters in front and after the version itself.

fliiiix avatar Apr 09 '25 12:04 fliiiix