Comments don't actually have any content to them #163

Closed
opened 2025-06-06 00:15:54 +00:00 by aidan9382 · 2 comments
Member

If you use the comments API manually (e.g. via python, r = requests.post("https://maps.strafes.net/api/mapfixes/1/comment", data="test", cookies={"session_id": session_id}, headers={"Content-Type": "text/plain"}); r), the comment will be created but will be recorded as being an empty string
image.png (from https://maps.strafes.net/api/mapfixes/1/audit-events?Page=1&Limit=100)
Not sure if this is me somehow using the API wrong or if there's a bug in the API where the data is somehow lost

If you use the comments API manually (e.g. via python, `r = requests.post("https://maps.strafes.net/api/mapfixes/1/comment", data="test", cookies={"session_id": session_id}, headers={"Content-Type": "text/plain"}); r`), the comment will be created but will be recorded as being an empty string ![image.png](/attachments/b4a193c4-e3ca-46ad-a067-421f46991073) (from https://maps.strafes.net/api/mapfixes/1/audit-events?Page=1&Limit=100) Not sure if this is me somehow using the API wrong or if there's a bug in the API where the data is somehow lost
aidan9382 added the bugbackend labels 2025-06-06 00:15:54 +00:00
Owner

The relevant code is located here:

data := []byte{}
_, err = req.Read(data)
if err != nil {
return err
}
Comment := string(data)

The req.Read(data) is supposed to put the request bytes into the data bytes, but it's the only place that type of call is used. I guess I never tested it. Not sure what the solution should look like.

Is data="test" the function body in your python example? The openapi spec accepts the comment in the POST body:

/mapfixes/{MapfixID}/comment:
post:
summary: Post a comment to the audit log
operationId: createMapfixAuditComment
tags:
- Mapfixes
parameters:
- $ref: '#/components/parameters/MapfixID'
requestBody:
required: true
content:
text/plain:
schema:
type: string
maxLength: 1024

The relevant code is located here: https://git.itzana.me/StrafesNET/maps-service/src/commit/e89abed3d51f5e9906b2b83aae7bf9d24f5acd23/pkg/service/audit_events.go#L46-L51 The `req.Read(data)` is supposed to put the request bytes into the data bytes, but it's the only place that type of call is used. I guess I never tested it. Not sure what the solution should look like. Is `data="test"` the function body in your python example? The openapi spec accepts the comment in the POST body: https://git.itzana.me/StrafesNET/maps-service/src/commit/e89abed3d51f5e9906b2b83aae7bf9d24f5acd23/openapi.yaml#L298-L312
Author
Member

Is data="test" the function body in your python example? The openapi spec accepts the comment in the POST body:

Yes, data is the body of the request sent after all the headers (I regularly try to call post with body=xyz first, error, and realise it's called data instead). Judging from the spec, it would've rejected me if my body was empty

> Is data="test" the function body in your python example? The openapi spec accepts the comment in the POST body: Yes, data is the body of the request sent after all the headers (I regularly try to call post with `body=xyz` first, error, and realise it's called data instead). Judging from the spec, it would've rejected me if my body was empty
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: StrafesNET/maps-service#163