Can't create new resources

Expected behavior

Should be able to create a new resource with given permissions

Actual behavior

After filling the form for creating a new resource I get the error: collection can’t be found and this is thrown in the console:


I’m not sure if this is related, but we noticed this happening after upgrading Forest Admin to the new roles system. We can’t create any resources now.
I have no idea what this error is about and it doesn’t give us a clue that is something in the routes or so.
I’d appreciate some help here asap. Thanks!

Hello @nathanqueija,

Could you please check that the role assigned to user user trying to create a record has correct create permission?

Also a screencast of the creation and submitting the form would help. You can do it with loom for example

Thank you

Yes, it does have the correct permission. I see the record created on the database so the route is definitely being processed correctly. It looks like it’s an issue on the frontend processing the response.

Okay, so your record is created, and the error happens after you saw the green toastr about successfully created record?

If you try to access this record from the record list, are you able to open it without any issue?

Could you please check the Network tab of your developer console to see if there are any failed requests?

Thank you

One more thing, you development environment is not impacted by the roles. Could you please try the creation in development environment so we can check if it roles related issue or not? Thanks

Exactly. I get the green toastr saying that the record has created successfully, but then I get this screen:

The only request failing is this one: https://api.forestadmin.com/api/activity-logs-requests

curl 'https://api.forestadmin.com/api/activity-logs-requests' \
  -H 'Connection: keep-alive' \
  -H 'Pragma: no-cache' \
  -H 'Cache-Control: no-cache' \
  -H 'Forest-Project-Id: 41863' \
  -H 'sec-ch-ua-mobile: ?0' \
  -H 'Authorization: Bearer 'token secret here' \
  -H 'Forest-Rendering-Id: 86429' \
  -H 'Content-Type: application/vnd.api+json' \
  -H 'Accept: vnd.forestadmin-api+json; version=2.8.1' \
  -H 'Forest-Environment-Id: 70866' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.114 Safari/537.36' \
  -H 'Forest-Collection-Id: templates' \
  -H 'Forest-Team-Id: 56458' \
  -H 'sec-ch-ua: "Google Chrome";v="89", "Chromium";v="89", ";Not A Brand";v="99"' \
  -H 'Origin: http://app.forestadmin.com' \
  -H 'Sec-Fetch-Site: cross-site' \
  -H 'Sec-Fetch-Mode: cors' \
  -H 'Sec-Fetch-Dest: empty' \
  -H 'Referer: http://app.forestadmin.com/' \
  -H 'Accept-Language: en-GB,en-US;q=0.9,en;q=0.8' \
  --data-raw '{"data":{"id":"2","attributes":{"type":"write","action":"create","label":"created","records":[null],"timing_interface":null,"timing_request":null},"relationships":{"rendering":{"data":{"type":"renderings","id":"86429"}},"collection":{"data":{"type":"collections","id":"templates"}}},"type":"activity-logs-requests"}}' \
  --compressed

I’m also able to open the newly created resource if I manually go back to the table view.

The same issue happens in all envs. And after I upgraded to the new roles system now I have two Dev environments. They are duplicated in the UI, but there is only one dev environment created in the settings area.

If the issue happens in the development environment, I don’t think it’s related to roles.

Do you have any custom logic in the creation route?

Do you have all the data and references saved correctly?

I don’t know if it’s related to roles. I noticed that this started to happen after we migrated to the new roles system. Maybe it’s not related, but that’s not the core of the issue I think.
In the creation route, we call an API, it’s a smart collection. It was working before and we didn’t change anything in the creation route.

What do you mean by: “Do you have all the data and references saved correctly?”
I don’t understand what you mean by data and references.

Would you mind sharing with me the definition of your create route, so I can try to reproduce the issue? You can send it to me in a private message.

When I ask if you have all the data and references I mean that you have all the inputted data saved correctly and if you have some references to other collections in this data they are correctly saved and shown as well;. When you reopen the record after manually going back to the table view.

Ah I see. Thanks for the clarification. We don’t have any references for this model. The data is saved correctly. I’ll send you the code for the create route via private message.

Thank you, I will do some tests on my end and let you know if I can find the issue.

Ah, one thing that I forgot: even though the resource was created in the database there is no activity log on Forest Admin for this action. Sometimes, the API call for the activity logs is failing with 500 randomly: https://api.forestadmin.com/api/rendering/86432/activity-logs?page[number]=1

So there is not activity log for any of the failing resource creations or just for some? Does this error occurs randomly or systematically after the creation bug?

Also, you mentioned that this error happens for the smart collection, are you able to create records for other collections without issues or is the problem global?

There is no activity record after the creation bug, but after this error happened I can’t see any activity logs in the Activity tab anymore. The API call always returns 500.
This is the only collection we have creation action, all the other collections in our app are read-only. This is the first one we’re trying to implement the creation capability.

You have this Dev environment, is it supposed to be a development or remote environment? This duplication issue can be caused by wrong environment type detection.

As for record creation, I am still working on reproducing the error

The dev environment is a remote environment. I have another environment for local development.

Would it be an issue for you to rename it to something not containing Dev in the name? For example Staging? It might solve the duplication issue

I renamed it to Development, now I have two environments named Development :sweat_smile:
It was called only Dev before.