ODM2 / ODM2DataSharingPortal

A Python-Django web application enabling users to upload, share, and display data from their environmental monitoring sites via the app's ODM2 database. Data can either be automatically streamed from Internet of Things (IoT) devices, manually uploaded via CSV files, or manually entered into forms.
BSD 3-Clause "New" or "Revised" License
31 stars 8 forks source link

create new site Server Error 500 hurrah still created #663

Closed neilh10 closed 7 months ago

neilh10 commented 1 year ago

On attempting to create new site I get Server Error 500

image

however they are created image

neilh10 commented 1 year ago

I guess an anomaly - all been working since then.

neilh10 commented 1 year ago

Happened again for someone else - seems like its not an anomaly. https://www.envirodiy.org/topic/registering-a-new-site-on-mmw/

ScottEnsign commented 1 year ago

Indeed, this is a recurring issue. @ptomasula examined this issue in May 2023 for another user and was not able to offer a resolution.

ptomasula commented 1 year ago

I have successfully recreated this issue and it appears related to #668 (which I just opened). If you do not select the Notify me if site stops receiving sensor data option, I can get the form to submit without a 500 error. I suspect that fixing and closing #668 will resolve this issue as well. In the interim you can create a site by not checking that option.

ptomasula commented 1 year ago

Our other user was still reporting issues even after I closed #668. Further investigation revealed this was related to some legacy data integrity issues in the affiliations table. Efforts were previously undertaken prior to release 0.15 to address these data issues, but four additional accounts where not successfully matched during that process. I added affiliation records for these accounts. Waiting for confirmation this addresses the problem for them before closing this issue.

ptomasula commented 1 year ago

We did successfully resolve this issue for the other user and determined it was related to missing records in the affiliations table. This resolves the immediate issue and will allow users to create sites again without issue. However, a review of the relevant code revealed that there is an remaining issue that can result in sites being partially created, with site information being created in one of the two relevant data tables. When the right conditions are met, those records will persist even with site generation failure. I recommend that the following refactoring be undertaken when time permits.

neilh10 commented 1 year ago

@ptomasula thanks very much for the info. Looking at error codes, as defined by https://en.wikipedia.org/wiki/List_of_HTTP_status_codes 500 Internal Server Error A generic error message, given when an unexpected condition was encountered and no more specific message is suitable.

400 Bad Request - The server cannot or will not process the request due to an apparent client error (e.g., malformed request syntax, size too large, invalid request message framing, or deceptive request routing).

From the "hydrologic user" using MMW screens to query a nodes data, it should just work by the options allowed on the screen. From an integrated programming nexus - there is the MMW screens that construct a POST, that is then sent to the backend server. In proposing a 400 is returned from the server (a step up from the 500), its actually an "internal" debug message that the HTML interface page constructing the POST, has not been constructed to the rules the backend server processes the request.

So is this a messy turd, with the issue being there isn't a defined RESTful interface between the front end MMW html and the back end server?. I haven't seen any descriptions of the back end server POST processing - and maybe I wouldn't want to - hopefully it just works.

aufdenkampe commented 7 months ago

The main issue here is resolved.

These side issues will be tracked under the following, which we plan to address with our v0.18 Milestone: