Closed erauner12 closed 5 months ago
curl --request POST \
--url https://memos.apidocumentation.com/api/v2/__NAME__/comments \
--data '{
"comment": {
"content": "",
"visibility": "VISIBILITY_UNSPECIFIED"
}
}'
https://memos.apidocumentation.com/reference#tag/memoservice/post/api/v2/{name}/comments
Hi @boojack
I'm still unclear about the resolution. I hope you can help me understand.
In this example, I need to fetch a specific memo and leave a comment on it. Here's how I'm constructing the GET and POST requests.
GET Request:
curl --request GET \
--url https://memos.apidocumentation.com/api/v2/__NAME_3__
HOST="<host>"
TOKEN="<token>"
MEMO_NAME="memos/90"
curl --request GET \
--url https://$HOST/api/v2/$MEMO_NAME \
-H "Authorization: Bearer $TOKEN" \
| jq
This fetches a memo with the name memos/90
. It seems to work as expected, returning the correct data:
{
"memo": {
"name": "memos/90",
"uid": "TCdDSCEPHS2V9SgbouDMeB",
"rowStatus": "ACTIVE",
"creator": "users/1",
"createTime": "2024-04-22T16:15:12Z",
"updateTime": "2024-04-22T16:15:12Z",
"displayTime": "2024-04-22T16:15:12Z",
"content": "test",
"visibility": "PRIVATE",
"pinned": false,
"resources": [],
"relations": [],
"reactions": []
}
}
However, when I try to post a comment on this particular memo, I construct the POST request as follows:
curl --request POST \
--url https://memos.apidocumentation.com/api/v2/__NAME__/comments \
--data '{
"comment": {
"content": "",
"visibility": "VISIBILITY_UNSPECIFIED"
}
}'
POST Request:
HOST="<host>"
TOKEN="<token>"
MEMO_NAME="memos/90"
curl --request POST \
--url https://$HOST/api/v2/$MEMO_NAME/comments \
-H "Authorization: Bearer $TOKEN" \
--data '{
"comment": {
"content": "test comment",
"visibility": "VISIBILITY_UNSPECIFIED"
}
}'
I'm unsure if I'm passing the correct memo name in this request. The target URL is constructed like this: https://$HOST/api/v2/memos/90/comments
. When I send this post request, my server crashes?
Could you confirm if this structure is correct, or point out any errors? Thank you for your assistance.
I think the server might be expecting a name
or something:
2024/04/26 03:30:21 ERROR CreateMemoComment request request="name:\"memos/18\" comment:{content:\"testsfasdfasdf\" visibility:PRIVATE}"
this works fine when sent from the web app, but if you try to send it via API request. That's when it crashes the server.
...
Got the development container running, but I could figure out how to reproduce the error with a curl from my local, kept getting errors.
I'm also seeing this behavior. Attempting to add a comment through the API takes down the server.
memos | panic: runtime error: invalid memory address or nil pointer dereference
memos | [signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0xc5aa6c]
memos |
memos | goroutine 298 [running]:
memos | github.com/usememos/memos/server/route/api/v2.(*APIV2Service).CreateMemo(0x4000428780, {0x1435568, 0x400063d8f0}, 0x0)
memos | /backend-build/server/route/api/v2/memo_service.go:42 +0x4c
memos | github.com/usememos/memos/server/route/api/v2.(*APIV2Service).CreateMemoComment(0x4000428780, {0x1435568, 0x400063d8f0}, 0x400062b000)
memos | /backend-build/server/route/api/v2/memo_service.go:340 +0x118
memos | github.com/usememos/memos/proto/gen/api/v2._MemoService_CreateMemoComment_Handler.func1({0x1435568?, 0x400063d8f0?}, {0x10d5060?, 0x400062b000?})
memos | /backend-build/proto/gen/api/v2/memo_service_grpc.pb.go:562 +0xd0
memos | github.com/usememos/memos/server/route/api/v2.(*GRPCAuthInterceptor).AuthenticationInterceptor(0x4000418138, {0x1435568, 0x400063d740}, {0x10d5060, 0x400062b000}, 0x400007e8a0, 0x4000680e70)
memos | /backend-build/server/route/api/v2/acl.go:80 +0x320
memos | google.golang.org/grpc.getChainUnaryHandler.func1({0x1435568, 0x400063d740}, {0x10d5060, 0x400062b000})
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1205 +0xa0
memos | github.com/usememos/memos/server/route/api/v2.(*LoggerInterceptor).LoggerInterceptor(0x1f35ca0, {0x1435568, 0x400063d740}, {0x10d5060?, 0x400062b000?}, 0x400007e8a0, 0x18?)
memos | /backend-build/server/route/api/v2/logger_interceptor.go:20 +0x4c
memos | google.golang.org/grpc.NewServer.chainUnaryServerInterceptors.chainUnaryInterceptors.func1({0x1435568, 0x400063d740}, {0x10d5060, 0x400062b000}, 0x400007e8a0, 0x113ff40?)
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1196 +0x88
memos | github.com/usememos/memos/proto/gen/api/v2._MemoService_CreateMemoComment_Handler({0x11a1660, 0x4000428780}, {0x1435568, 0x400063d740}, 0x4000630680, 0x400036bb80)
memos | /backend-build/proto/gen/api/v2/memo_service_grpc.pb.go:564 +0x148
memos | google.golang.org/grpc.(*Server).processUnaryRPC(0x40002fee00, {0x1435568, 0x400063d680}, {0x143eec0, 0x40003861a0}, 0x4000646240, 0x4000428a50, 0x1eb9ba8, 0x400062afc0)
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1385 +0xb40
memos | google.golang.org/grpc.(*Server).handleStream(0x40002fee00, {0x143eec0, 0x40003861a0}, 0x4000646240)
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1796 +0xc00
memos | google.golang.org/grpc.(*Server).serveStreams.func2.1()
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1029 +0x8c
memos | created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 48
memos | /go/pkg/mod/google.golang.org/grpc@v1.61.1/server.go:1040 +0x13c
memos exited with code 2
@boojack Can we reopen this issue? Another person above also encountered the same error, suggesting it's not caused by calling the memoservice
incorrectly. Let me know if you need more details, and I can provide them.
Describe the bug
The problem is that anytime I try to leave a comment via the API, it actually crashes the memos instance:
I have to start the container back up after each time that it happens.
I was following this:
https://memos.apidocumentation.com/reference#tag/memoservice/post/api/v2/{name}/comments
Steps to reproduce
Easy way to re-create
Error
The version of Memos you're using
Version: v0.21.0 (stable image tag)
Screenshots or additional context
No response