-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
Prevent infinite relationship nesting loop #133
Comments
Are you able to provide the response it's receiving? I can't replicate this issue in the demo on codepen: https://codepen.io/wopian/pen/RxmEeK |
I put up a Mock API to test on: http://demo9418135.mockable.io/printers?include=paper,labels I can not get codepen to call that, i tried it like this: const printerApi = new Kitsu({
baseURL: 'http://demo9418135.mockable.io/',
})
printerApi.get('printers', {include: 'paper,labels'})
.then(res => {
const pre = document.getElementsByTagName('pre')[0];
pre.innerHTML = JSON.stringify(res, null, 2)
}) The problem may be related to using a plural include (labels) and a singular include (paper) in the same request. paper actually refers to a resource with the type papers. |
You'd need to give it the The response you've provided has the included While this is a valid JSON:API structure, it is not a valid response for the query provided. The {
relationships: {
paper: {
links: { self: '', related: '' }
}
}
}
This is causing {
data: {
type: 'printers',
paper: {
labels: [
paper: { labels [ /* infinitely nest papers and printers */ ] },
printers: [ { /* infinitely nest root data structure again */ } ]
],
},
labels: [
paper: { labels [ /* infinitely nest papers and printers */ ] },
printers: [ { /* infinitely nest root data structure again */ } ]
]
}
} Which quite quickly locks up the runtime in what's basically a DOS attack. Less of an issue in browsers as they can detect and kill the process when this happens. In node it killed my distro when added to jest's tests. |
Hi there, |
Not being actively looked into at the moment. PRs are welcome in the meantime however. Possible solutions
|
Is this still an issue now after #601 landed? |
All is fine if i make such a request:
This works as well:
And this returns 400 Bad Request:
But this causes to client to freeze, the Browsertab becomes unresponsive and i have to close it:
I tried sending the request from elsewhere, no problem whatsoever. Maybe Kitsu can not deal with multiple includes?
The text was updated successfully, but these errors were encountered: