flathub-infra / flat-manager-hooks

Hooks for integrating Flathub's backend with flat-manager
Apache License 2.0
2 stars 4 forks source link

flat-manager fails to encode nested JSON #67

Open barthalion opened 12 months ago

barthalion commented 12 months ago

I think that since the hooks were changed to use flatpak-builder-lint for doing the build validation, /build/:id/check/:check/job endpoints became completely broken.

~/d/f/flat-manager master• [1] https -x -A bearer -a $flattoken hub.flathub.org/api/v1/build/57602/check/flathub-hooks/job Content-Type:application/json
HTTP/1.1 400 Bad Request
Connection: keep-alive
Content-Length: 68
Content-Type: text/plain; charset=utf-8
Date: Sun, 22 Oct 2023 21:05:19 GMT
Server: nginx/1.18.0 (Ubuntu)

Json deserialize error: EOF while parsing a value at line 1 column 0

f-b-l returns errors, if any, as JSON. I suspect the nested JSON confuses flat-manager, as it somehow works for /extended, but is double escaped:

~/d/f/flat-manager master• ❱ https -x -A bearer -a $flattoken hub.flathub.org/api/v1/build/57602/extended Content-Type:application/json
HTTP/1.1 200 OK
Connection: keep-alive
Content-Encoding: gzip
Content-Type: application/json
Date: Sun, 22 Oct 2023 21:06:50 GMT
Server: nginx/1.18.0 (Ubuntu)
Transfer-Encoding: chunked
Vary: Accept-Encoding, Accept-Encoding

{
    "build": {
        "app_id": null,
        "build_log_url": "https://buildbot.flathub.org/#/builders/6/builds/74969",
        "commit_job_id": 91268,
        "created": "2023-10-19T20:50:14.517054",
        "extra_ids": [],
        "id": 57602,
        "public_download": true,
        "publish_job_id": 91380,
        "published_state": 2,
        "repo": "stable",
        "repo_state": 5
    },
    "build_refs": [
        {
            "build_id": 57602,
            "build_log_url": null,
            "commit": "3cd7156a5638dda05157d7de5c4ebe749790a2bfb47089d195fa60f3f0017e61",
            "id": 377192,
            "ref_name": "screenshots/x86_64"
        },
        {
            "build_id": 57602,
            "build_log_url": null,
            "commit": "17f3f94f7747234dc49bc4138090627af2ef500c4c6cdc35fd66202df60211c2",
            "id": 377193,
            "ref_name": "app/com.github.micahflee.torbrowser-launcher/x86_64/stable"
        },
        {
            "build_id": 57602,
            "build_log_url": null,
            "commit": "384d195f4048cbd40248fe196a0fed2b37c9267a3515e018521af6d3f5f1fc44",
            "id": 377194,
            "ref_name": "runtime/com.github.micahflee.torbrowser_launcher.Debug/x86_64/stable"
        },
        {
            "build_id": 57602,
            "build_log_url": null,
            "commit": "5445147bad21846b4a357cdc1efb9d7a1efa2126051a99cf44ca9bc1de40439d",
            "id": 377195,
            "ref_name": "runtime/com.github.micahflee.torbrowser_launcher.Sources/x86_64/stable"
        }
    ],
    "checks": [
        {
            "build_id": 57602,
            "check_name": "flathub-hooks",
            "job_id": 91269,
            "results": "{\"diagnostics\":[{\"refstring\":\"app/com.github.micahflee.torbrowser-launcher/x86_64/stable\",\"is_warning\":false,\"category\":\"flatpak_builder_lint\",\"data\":{\"stdout\":{\"errors\":[\"appstream-missing-developer-name\",\"appstream-failed-validation\"],\"warnings\":[\"finish-args-contains-both-x11-and-wayland\",\"finish-args-contains-both-x11-and-fallback\"]},\"stderr\":\"\"}}]}",
            "status": 2,
            "status_reason": "One or more validations failed."
        }
    ]
}
jameswestman commented 11 months ago

get_check_job takes a JSON argument for the log offset (which is wrong for a GET request, but that's what the other job endpoint does...). Is that the issue?

barthalion commented 11 months ago

The issue is that the endpoint fails also without passing the log offset.