Closed visualcookie closed 5 years ago
Hi!
Do you think you could supply me with a database dump of your current configuration so that I could try and recreate the issue on my end?
Hey @Jonesus, sure. I did a dump of the post collection, guess that should be enough, right?
From what I can see now is, that the teaser
field in there is NULL
. When I go to my post, and check, there is in fact no teaser image, but it was there when I saved and it's in my file library as well. When I select the image on the post I'm editing, I get a Directus error Internal Server Error
. Guess it has something to do with Directus then?
Dump => posts.gz
Awesome, thanks! Do you think you could also supply the directus_relations
table, as there might be some weird relation artifacts going on messing with the proper linking?
Hey, I don't have the same setup as yesterday available anymore. I'm just testing the translations right now and have removed the images for now. I may come back to this issue, when #12 has been figured out.
I first encountered a similar issue when Directus included old relations that could not be found. This appears to be a bug in Directus that causes old relations to hang around and a bug in this code that attempts to find a table that does not exist. Unfortunately, I do not remember where this was in the code. I'll try to look for it.
The second time I encountered this issue, it was because the image column was NULL. The error is in the following code:
collectionsWithFiles.forEach(c => {
info(`Mapping files for ${c.collectionName}...`);
newEntities[c.collectionName] = newEntities[c.collectionName].map(e => {
const targetFileId = e[c.fieldName];
const fileId = files.find(f => f.directus.directusId === targetFileId).directus.id;
return { ...e, [`${c.fieldName}___NODE`]: fileId };
});
Notice that the output of files.find(...)
is directly accessed right after. The file object should be checked to ensure that it is defined before attempting to access .directus.id
. The issue in this case was that null is not an actual file ID, so it wasn't found.
Here is some code that might fix the problem:
collectionsWithFiles.forEach(c => {
info(`Mapping files for ${c.collectionName}...`);
newEntities[c.collectionName] = newEntities[c.collectionName].map(e => {
const targetFileId = e[c.fieldName];
const fileObject = files.find(f => f.directus.directusId === targetFileId);
if (!fileObject || !fileObject.directus || !fileObject.directus.id) {
warn(
`Cannot find file with ID ${targetFileId}. Please check that the field ` +
+ `${c.fieldName} in the collection ${c.collectionName} is filled out.`
);
return e;
}
const fileId = fileObject.directus.id;
return { ...e, [`${c.fieldName}___NODE`]: fileId };
});
(Standard disclaimer: I haven't tested it yet :P )
Thanks @KB1RD ! Now that I've dug a bit more into issues like these I've noticed that some of the object accesses are quite greedy and have probably caused more of similar issues... I'm in progress of writing a test suite for the package (something that should've been done a long time ago...) so that all similar issues would get caught. I'll try your solution out and also try and find similar holes in the code and push out a patch soon-ish!
Hey @visualcookie and @KB1RD ! I pushed a new v0.8.0 release which should hopefully address these issues, let me know if they still persist for you after this!
Hey @Jonesus. Thanks for the update. Will give it a try with some articles tomorrow and give you feedback on that as soon as I have something ready.
Works. 👍
Hey.
I have this weird issue, that after a couple of minutes and a fresh
yarn start
, the plugin is returning errors. I don't know what exactly is causing the issue.UPDATE: This issue only happens, if there is an image in the content or in the teaser field.
Plugin part from logs:
Posts collection: