Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InternalServerError: Cast to ObjectId failed for value "5" at path "_id" for model "comment" #15

Closed
cyp3rius opened this issue Dec 7, 2020 · 5 comments · Fixed by #17
Assignees
Labels
bug Something isn't working solved Issue has been solved

Comments

@cyp3rius
Copy link
Collaborator

cyp3rius commented Dec 7, 2020

Having a somewhat related issue. I get the following error message when I go to "Plugins" -> "Comments" -> Comment I just posted.

error InternalServerError: Cast to ObjectId failed for value "5" at path "_id" for model "comment"

Screen Shot 2020-12-05 at 11 28 13 AM

This is what I POST to create a new comment (not sure maybe thats where the issue is?)

{
    "authorUser": "5fb48e746b458f4dc1da0751",
	"content": "My sample response",
	"related": [{
		"refId": "5fcba9fee5e1787e022cf178",
		"ref": "post",
		"field": "comments"
	}]
}

refId is the ID of the post I am trying to comment on. Same ID is being supplied via the endpoint:

POST http://localhost:1337/comments/post:5fcba9fee5e1787e022cf178 (not sure if it needs to be supplied in both places: URL and the body of the request)

When I go to that post I can definitely see that the new comment was "propagated":

Screen Shot 2020-12-05 at 11 35 19 AM

Any ideas?

Originally posted by @mikekoro in #14 (comment)

@cyp3rius
Copy link
Collaborator Author

cyp3rius commented Dec 7, 2020

@mikekoro @ibnumubarok what version of Strapi and plugin are you using? May I ask for the full stack trace?

@cyp3rius cyp3rius self-assigned this Dec 7, 2020
@cyp3rius cyp3rius added the bug Something isn't working label Dec 7, 2020
@ibnumubarok
Copy link

Thanks for opening a new issue @cyp3rius

I'm using the latest version, for both Strapi (3.3.4) & plugin (1.0.0-beta.6).

After trying to do another look on this, I found that this issue related with MongoDB datatype. If I setup Strapi using SQLite, the plugin works well, but error when I use MongoDB.

ID of an entry on MongoDB is an ObjectID, while on other db, it's an integer. This cause the error.

[2020-12-07T12:09:02.029Z] error InternalServerError: Cast to ObjectId failed for value "5" at path "_id" for model "comment"
at Object.throw (/Users/ibnu/work/temp/strapi-comment/node_modules/koa/lib/context.js:97:11)
at throwError (/Users/ibnu/work/temp/strapi-comment/node_modules/strapi-plugin-comments/controllers/comments.js:18:41)
at Object.findOne (/Users/ibnu/work/temp/strapi-comment/node_modules/strapi-plugin-comments/controllers/comments.js:119:7)
at runMicrotasks ()
at processTicksAndRejections (internal/process/task_queues.js:97:5)

@cyp3rius
Copy link
Collaborator Author

cyp3rius commented Dec 7, 2020

Thanks for highlighting that @ibnumubarok. I will prepare the fix in couple of hours.

@cyp3rius
Copy link
Collaborator Author

cyp3rius commented Dec 7, 2020

@ibnumubarok @mikekoro version beta.7 has been published with the uuid fix. Close the ticket once it helps.

@cyp3rius cyp3rius linked a pull request Dec 7, 2020 that will close this issue
@cyp3rius cyp3rius added solved Issue has been solved waiting for feedback Waiting for reported feedback labels Dec 8, 2020
@cyp3rius
Copy link
Collaborator Author

cyp3rius commented Dec 9, 2020

Closing. In case of need raise a new ticket please.

@cyp3rius cyp3rius closed this as completed Dec 9, 2020
@cyp3rius cyp3rius removed the waiting for feedback Waiting for reported feedback label Dec 9, 2020
github-actions bot pushed a commit to zrp/uqbar-strapi-plugin-comments that referenced this issue Jan 13, 2023
# 1.0.0 (2023-01-13)

### Bug Fixes

* [CU-21mwg4m] apply strapi team review comments ([88ee04b](88ee04b))
* [CU-21mwg4m] status badge sizing ([80c7946](80c7946))
* [CU-232p7qk] fallback config from local file ([9f9a43e](9f9a43e))
* [CU-23e47df] pagination and sort via rest api ([1eeb742](1eeb742))
* [CU-862hz23aa] Translations init failure while async loading ([VirtusLab-Open-Source#181](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/181)) ([dd665d9](dd665d9))
* avatar and initials rendering ([812afb2](812afb2))
* circle ci directory fix ([74b75ed](74b75ed))
* circle ci directory fix ([#10](#10)) ([0c998eb](0c998eb))
* compatibility with strapi 3.6.x ([VirtusLab-Open-Source#50](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/50)) ([81f69a8](81f69a8))
* dependabot alert for dicer ([e794a9b](e794a9b))
* dependabot dicer alert ([0bb17db](0bb17db))
* dependencies conflict ([c2c7e17](c2c7e17))
* filtering only root level ([VirtusLab-Open-Source#35](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/35)) ([62a90be](62a90be))
* find all in hierarchy fix ([735fbac](735fbac))
* gql and missing nexus dependency ([a438f41](a438f41))
* issue [VirtusLab-Open-Source#104](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/104) interface crashing if related content type removed ([ace336c](ace336c))
* issue [VirtusLab-Open-Source#116](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/116) - bad words filtering turned on when it shouldn't ([240082e](240082e))
* issue [VirtusLab-Open-Source#15](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/15) uuid parsing in mongo ([VirtusLab-Open-Source#17](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/17)) ([7ab3ed3](7ab3ed3))
* issue [#2](#2) search by relation slug ([#3](#3)) ([22eaebe](22eaebe))
* issue-110 gql configuration not applying, issues with old configurations ([ff662d3](ff662d3))
* lack of plugin config to reflect gql schema ([VirtusLab-Open-Source#77](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/77)) ([5fdd8ba](5fdd8ba))
* lack of user data sanitization ([c6957e5](c6957e5))
* make withCount default for GraphQL queries ([5717902](5717902))
* missing translation ([4de9390](4de9390))
* multiple fields population malformed ([f4726ac](f4726ac))
* problem with ref on create ([70bc620](70bc620))
* problems with details on comment ([0a17fd7](0a17fd7))
* problems with drill down ([d1a43d1](d1a43d1))
* query null error ([30dbf17](30dbf17))
* readme wording ([fe990b0](fe990b0))
* relation slug missing while cregistering comment ([9a1ba1c](9a1ba1c))
* relations & content types slugs ([b477c7e](b477c7e))
* remove codecov orb ([8740eca](8740eca))
* undefined sort parameter rejected by strapi query ([db749ea](db749ea))
* version bump ([3e32dc3](3e32dc3))
* wrapped where param in db query ([VirtusLab-Open-Source#152](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/152)) ([bd652c3](bd652c3))

### Features

* [CU-20y7quq] gql handle auth and user context linking ([d4d22ba](d4d22ba))
* [CU-20y7quq] handle user context linking ([39f728c](39f728c))
* [CU-220ekmx] provide sort and pagination support in findAll and findAllInHierarchy methods ([5c1ab4f](5c1ab4f))
* [CU-23e4bnk] ([d363b6f](d363b6f))
* [CU-23ku6zz] apply strapi pagination spec to findallflat endpoint ([c93b3a1](c93b3a1))
* [CU-2ep5xe1] [CU-2eap4ev] inform commenter about responses & avatar fix ([VirtusLab-Open-Source#143](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/143)) ([c7d664a](c7d664a))
* add tests to ci ([VirtusLab-Open-Source#159](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/159)) ([7cf6474](7cf6474))
* bad words customization ([VirtusLab-Open-Source#33](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/33)) ([f1fad77](f1fad77))
* codecov setup ([#11](#11)) ([d3950bf](d3950bf))
* comments pre-moderation ([VirtusLab-Open-Source#68](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/68)) ([8cab133](8cab133))
* context user support ([VirtusLab-Open-Source#23](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/23)) ([1d1354b](1d1354b))
* control gql auth via form ([2000942](2000942))
* custom fields on server-side [CU-xhcmx-63] ([VirtusLab-Open-Source#161](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/161)) ([a7737c8](a7737c8))
* report email notification ([VirtusLab-Open-Source#83](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/83)) ([a0585ed](a0585ed))
* strapi 3.1.0 rbac support ([#4](#4)) ([eb36adf](eb36adf))
* support for query parameters ([VirtusLab-Open-Source#34](https://github.com/zrp/uqbar-strapi-plugin-comments/issues/34)) ([753dc0c](753dc0c))
* **UQ-1853:** changed admin ([2590100](2590100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working solved Issue has been solved
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants