I have…
- Read the following guideline: Troubleshooting and Support | Squidex. I understand that my support request might get deleted if I do not follow the guideline.
- Used code blocks with ``` to format my code examples like JSON or logs properly.
I’m submitting a…
- Regression (a behavior that stopped working in a new release)
- Bug report
- Performance issue
- Documentation issue or request
Current behavior
Either this is a bug or I don’t know what I’m doing. (Hint: The current docs leave more docs to be desired.) The interface seems fairly obvious to me though. And I’m using it the way it seems like the API docs say to use it, and how it appears to be used by the admin UI in the Network tab of my Edge browser Dev Tools.
Which is: give it the schema and the content ID within the schema and it’ll give you the references back from your fields which contain references. So it’s probably not the docs or me or that I’m using wrong. So, this is what’s going on.
Node.js TypeScript await client.contents.getReferences('schema-name', 'valid-uuid')
throws:
Error: response: Missing required key "statuses"
at ...\node_modules\@squidex\squidex\core\schemas\builders\schema-utils\getSchemaUtils.js:25:19
at Generator.next (<anonymous>)
at fulfilled (...\node_modules\@squidex\squidex\core\schemas\builders\schema-utils\getSchemaUtils.js:5:58)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Expected behavior
await getReferences()
should return ContentsDto
instance.
Minimal reproduction of the problem
- Create a schema that includes a reference field. Assign a valid schema to reference in the admin UI for that reference field.
- Create and publish a content item for the schema including a valid reference to a content item.
- Take note of the schema name and content item UUID/GUID. Call the
await client.content.getReferences()
function using these two as actual parameters forgetReferences(schema: string, id: string)
formal parameters,schema
andid
, respectively. - Observe the thrown error.
Environment
App Name: dasher-supply
- Self hosted with docker
- Self hosted with IIS
- Self hosted with other version
- Cloud version
Version: 7.14.0.0
Browser:
- Chrome (desktop)
- Chrome (Android)
- Chrome (iOS)
- Firefox
- Safari (desktop)
- Safari (iOS)
- IE
- Edge
Others:
You can possibly observe it crashing here: https://dev.dashersupply.com/brand/coast
The code causing the crash, with console traces along the way:
console.log("routeLookup:", routeLookup!);
const redirectDto = await getRedirectsByPreviousSlug(routeLookup!);
console.log("redirectDto:", redirectDto);
if (redirectDto && redirectDto.items && redirectDto.items.length > 0) {
console.log("getting redirectReferencesDto for", SCHEMAS.REDIRECTS, redirectDto.items[0].id);
let redirectReferencesDto = await client.contents.getReferences(SCHEMAS.REDIRECTS, redirectDto.items[0].id);
console.log("redirectReferencesDto:", redirectReferencesDto);
//...
The console output on the Node.js frontend:
routeLookup: brand/coast
redirectDto: {
total: 1,
items: [
{
id: 'b4d983d9-94a3-4b6c-8b0e-15a949fa0f19',
createdBy: 'subject:66b10d503c72d885491f262f',
lastModifiedBy: 'subject:66b10d503c72d885491f262f',
data: [Object],
created: 2024-08-22T04:40:37.000Z,
lastModified: 2024-08-22T04:40:37.000Z,
status: 'Published',
statusColor: '#4bb958',
editToken: 'eyJhIjoiZGFzaGVyLXN1cHBseSIsInMiOiJyZWRpcmVjdHMiLCJpIjoiYjRkOTgzZDktOTRhMy00YjZjLThiMGUtMTVhOTQ5ZmEwZjE5IiwidSI6Imh0dHBzOi8vc3F1aWRleC5kYXNoZXJzdXBwbHkuY29tLyJ9',
schemaId: 'f0976cf8-e184-4b06-99c3-0a3e6bd56ec7',
schemaName: 'redirects',
schemaDisplayName: 'Redirects',
isDeleted: false,
version: 1,
links: [Object]
}
],
statuses: [
{ status: 'Archived', color: '#eb3142' },
{ status: 'Draft', color: '#8091a5' },
{ status: 'Published', color: '#4bb958' }
],
links: {
self: { href: '/api/content/dasher-supply/redirects', method: 'GET' },
create: { href: '/api/content/dasher-supply/redirects', method: 'POST' }
}
}
getting redirectReferencesDto for redirects b4d983d9-94a3-4b6c-8b0e-15a949fa0f19
02:06:32 [ERROR] Missing required key "statuses"
I temporarily assigned a permission of * to the API role just to make sure it wasn’t permissions. It’s not permissions. There’s something broken. I just don’t know what it is. Either that or I’m using it wrong, and that’s perfectly reasonable considering I’m guessing most of the time.
Using docker logs <container_name> | tail -n 100
I was able to locate the Squidex log for the particular server response which appears to have executed properly.
...
{
"logLevel": "Information",
"message": "HTTP request executed.",
"elapsedRequestMs": 2,
"filters": {
"appId": "8d415745-cc4b-41fb-b078-2614504d5497",
"appName": "dasher-supply",
"userId": "dasher-supply:dasher-supply-astro",
"clientId": "dasher-supply:dasher-supply-astro",
"costs": 1
},
"timestamp": "2024-08-22T06:38:17Z",
"app": {
"name": "Squidex",
"version": "7.14.0.0",
"sessionId": "e9804ee2-84e9-4c3a-8bc7-f0155c521678"
},
"web": {
"requestId": "00-d0c627c783ad2ffec661b7f0949560f2-3ff9dc8aa51be2b9-01",
"requestPath": "/api/content/dasher-supply/redirects",
"requestMethod": "GET"
}
}
{
"logLevel": "Information",
"message": "HTTP request executed.",
"elapsedRequestMs": 13,
"filters": {
"appId": "8d415745-cc4b-41fb-b078-2614504d5497",
"appName": "dasher-supply",
"userId": "dasher-supply:dasher-supply-astro",
"clientId": "dasher-supply:dasher-supply-astro",
"costs": 1
},
"timestamp": "2024-08-22T06:38:17Z",
"app": {
"name": "Squidex",
"version": "7.14.0.0",
"sessionId": "e9804ee2-84e9-4c3a-8bc7-f0155c521678"
},
"web": {
"requestId": "00-93f52d49681e10a211dd212ad5e26122-f9128313c186f0b9-01",
"requestPath": "/api/content/dasher-supply/redirects/b4d983d9-94a3-4b6c-8b0e-15a949fa0f19/references",
"requestMethod": "GET"
}
}
A potential workaround is to create a non-localized string field on the schema adjacent to the reference field, e.g., for a field named referenceField
create an adjacent field referenceFieldSchema
; then using a Create and Update Script pair in Squidex, automatically track the referenceField
’s schema name (which I presume should never change) using the server’s implementation of getReference()
which works similarly to the TypeScript SDK’s implementation. Then using the TypeScript client, perform a content item lookup using content.getContents()
with the id as referenceField[locale|'iv']
against the schema in referenceFieldSchema.iv
.
I don’t have an exact recipe for this Squidex Script yet because I would have to research how to use the server-side implementation of getReference()
which probably uses callbacks instead of Promises and async
/ await
. But I believe I could figure out the script faster than I can figure out why the client SDK isn’t working as expected.