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
Receive the original payload when using the 'request' or 'database' error flow events #21249
Comments
Looking through the code this was not a feature in Directus (9+) as version 9 was a complete rewrite we don't guarantee it to be feature complete with previous versions. Closing this issue for now as not a bug but feel free to create a feature request to get your wishes implemented. |
I've found the code that was responsible for this feature. It is seems to be removed after v10.3 during the introduction of the new error handling package. The old error handler included a field called function foreignKeyViolation(error: PostgresError) {
const { table, detail } = error;
const betweenParens = /\(([^)]+)\)/g;
const matches = detail.match(betweenParens);
if (!matches) return error;
const collection = table;
const field = matches[0].slice(1, -1);
const invalid = matches[1]!.slice(1, -1);
return new InvalidForeignKeyException(field, {
collection,
field,
invalid,
});
} Is there a way to get this feature back? |
Ah i see where the misunderstanding happened, the complete "original payload" was never in the error but we did have a field for the specific value that was failing indeed. |
Describe the Bug
(Reported as a bug, as this used to be a feature supported in previous versions. I can't recall when this change happened)
Given a collection
A
and ao2m
relationship with collectionB
through the fieldb_id
, if you attempt to provide a value forb_id
which has not yet been added to the collectionB
, you will receive a foreign key violation, which is to be expected.However, I would like to recover from this position by creating a flow which either uses the
request
or adatabase
error event. Unfortunately, the original payload (i.e.{ "b_id": "something" }
) isn't provided, thus making it hard to resolve the error by for instance creating thesomething
ID inside theB
collection.To Reproduce
Create the two collections as described above. Create a flow which uses the
request
ordatabase
error event on collectionA
, and enable logging. Now try to append an entry to collectionA
by specifying an invalidb_id
. Inside your log you will receive something like this:Ideally, you would receive something like this:
Directus Version
v10.8.3
Hosting Strategy
Self-Hosted (Docker Image)
The text was updated successfully, but these errors were encountered: