-
Notifications
You must be signed in to change notification settings - Fork 158
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
Set up the JavaScript library following installation steps in the Readme #804
Comments
all tests passing for the spectral-workbench.js setup
@jywarren I tried writing this example script from the spectral-workbench.js readme and manipulating the spectrum data, which ran successfully except for the experimental direct upload feature, which gave me a response of
|
Ah, i wonder if that route has also gotten broken? i'm glad you were able to get that far in generating a spectrum on the commandline! I wonder if it's due to some change in how Rails reads JSON submissions. It's not a typical error like a 500 or a 404 or something. A 406 may be linked to the formatting of the submission: https://stackoverflow.com/questions/3751030/rails-3-returning-a-http-406-not-acceptable These aren't super helpful except that they hint at a link between 406 errors and JSON. But the best way to debug this might be to run the Rails app locally too -- for example, you could run it at the usual Rails port 3000, so How does that sound? Thanks @Georjane !!! |
Oh one more! https://coolaj86.com/articles/rails-error-406.html |
On further investigating locally I think the token and title params are not getting passed correctly since it's entering the else condition ln 305 (spectrums_controller.rb) where the total body is not considered to be a json format hence the error Note: In this I am passing the title like this in data since it is being called as
I am still unsure since running this |
Thanks @jywarren
|
1 similar comment
Thanks @jywarren
|
OK, so let's look carefully at the exact full request, which as Rails reports in your last comment, would be: {"spectrum"=>{"title"=>"Jane spectrum", "data_type"=>"json", "data"=>"[{\"average\":64.3333,\"r\":69,\"g\":46,\"b\":78,\"wavelength\":269.089},{\"average\":63.3333,\"r\":71,\"g\":45,\"b\":74,\"wavelength\":277.718},{\"average\":64,\"r\":71,\"g\":47,\"b\":74,\"wavelength\":291.524},{\"average\":64,\"r\":68,\"g\":49,\"b\":75,\"wavelength\":303.604}]"}, "token"=>"xxxxxxxxxxxx"} As @Tlazypanda notes, maybe we need to look carefully at how it's being converted from JSON and accessed in Rails. Let's link in an excerpt of the exact controller method that's reading it, which from your log is spectral-workbench/app/controllers/spectrums_controller.rb Lines 202 to 228 in 8bbbe25
We can already see it's trying to access I see we also have spectral-workbench/app/controllers/spectrums_controller.rb Lines 223 to 225 in 8bbbe25
Let's go through each line and see what's happening, and if it's really getting the correct JSON data for each use of Interestingly, down on this line we say to return an error which corresponds to 422, not 406, i think?
Aha - here are a couple posts that seem pretty relevant!
There are a few ways to manage "format" or type, i.e. detecting if it's JavaScript sending something, if it's an XHR request, if the request ends in .json, etc. and I believe the conventions on this have changed over the years in Rails. We may be mistaken in how we're trying to get the code to recognize that we're dealing with a JS request, in JSON format. I think the first of the above links is the best place to look! Hope this helps, @Georjane -- thanks for sticking with this! |
And just for context - i think this direct means of uploading a spectrum is important -- but is not the way the JS library typically does it while running within the Rails app. This is more like a purely command-line utility which not too many people use. That's probably why it was broken and nobody noticed? |
Thanks @jywarren
|
Ah, maybe i misunderstood - if you have fixed the data format issue, why do you think you're still seeing the 406 error? I think a similar approach as I had mentioned - using rails log statements to see what happens at each step - could help diagnose this too. Let's see on what line it actually generates the 406 error? |
No description provided.
The text was updated successfully, but these errors were encountered: