When loading a specific association table in my account, I’m seeing the error TypeError: Cannot read property 'startsWith' of undefined in the logs and the UI is telling me that the server encountered an error.
Expected behavior
Expected to see the list of items from my table called “Recommendation Contents”
[forest] 🌳🌳🌳 Unexpected error: Cannot read property 'startsWith' of undefined
TypeError: Cannot read property 'startsWith' of undefined
at /Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:57:21
at Array.filter (<anonymous>)
at /Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:56:62
at Array.forEach (<anonymous>)
at QueryBuilder.getIncludes (/Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:52:8)
at getRecords (/Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/resources-getter.js:134:34)
GET /forest/recommendationContent?fields%5BexternalContent%5D=id&fields%5BrecommendationContent%5D=externalContent%2ClinkLabel%2Ctemplate&fields%5Btemplate%5D=id&page%5Bnumber%5D=1&page%5Bsize%5D=15&searchExtended=0&timezone=America%2FSao_Paulo 500 85 - 10.372 ms
[forest] 🌳🌳🌳 Unexpected error: Cannot read property 'startsWith' of undefined
TypeError: Cannot read property 'startsWith' of undefined
at /Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:57:21
at Array.filter (<anonymous>)
at /Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:56:62
at Array.forEach (<anonymous>)
at QueryBuilder.getIncludes (/Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/query-builder.js:52:8)
at countRecords (/Users/lucasbordignon/code/point-api/cms/Point Fitness Insights/node_modules/forest-express-sequelize/dist/services/resources-getter.js:174:34)
GET /forest/recommendationContent/count?fields%5BrecommendationContent%5D=externalContent%2ClinkLabel%2Ctemplate&fields%5BexternalContent%5D=id&fields%5Btemplate%5D=id&searchExtended=0&timezone=America%2FSao_Paulo 500 85 - 3.219 ms
Context
Please provide any relevant information about your setup.
Hmm it seems you have a badly formatted query parameters. Could you please share the request with all its query parameters decoded: ON chrome go to the network tab and show the query string parameters
For sure, here it goes for both requests that the app is making to the server (shown in the logs)
1st
fields[externalContent]: id
fields[recommendationContent]: externalContent,linkLabel,template
fields[template]: id
page[number]: 1
page[size]: 15
searchExtended: 0
timezone: America/Sao_Paulo
2nd
fields[recommendationContent]: externalContent,linkLabel,template
fields[externalContent]: id
fields[template]: id
searchExtended: 0
timezone: America/Sao_Paulo
Got it! Okay, so now I’ve created a primary key constraint with both fields now and I see that when accessing the database client, but still see the same error. I assume is my mistake in setting that up on the Lumber model definition
Could you give me guidance on how to add the constraint at the model?
I tried the following two approaches already
Add the .belongsToMany() at the associated models
Add the indexes key in my RecommendationContent model
But the error still happen in both scenarios, might be missing something that I couldn’t find in the docs