microbiomedata / nmdc-server

Data portal client and server for NMDC.
https://data.microbiomedata.org
Other
9 stars 0 forks source link

Unable to open submission #1148

Closed pkalita-lbl closed 8 months ago

pkalita-lbl commented 8 months ago

Currently in dev there is a backend error when trying to open any submission. The proximate cause is failing request to the GET /api/metadata_submission/{id} endpoint. For example: https://data-dev.microbiomedata.org/api/metadata_submission/b59b627c-1fb6-47d8-8e12-34f53f2647d1.

The error reported on the backend looks like this:

File "/app/nmdc_server/api.py", line 636, in get_submission
2024-02-21T23:47:23.213863339Z     return schemas_submission.SubmissionMetadataSchema(
2024-02-21T23:47:23.213867529Z   File "pydantic/main.py", line 342, in pydantic.main.BaseModel.__init__
2024-02-21T23:47:23.213873129Z pydantic.error_wrappers.ValidationError: 5 validation errors for SubmissionMetadataSchema
2024-02-21T23:47:23.213875409Z metadata_submission
2024-02-21T23:47:23.213877489Z   field requir
ed (type=value_error.missing)
2024-02-21T23:47:23.213879669Z status
2024-02-21T23:47:23.213881740Z   field required (type=value_error.missing)
2024-02-21T23:47:23.213883909Z id
2024-02-21T23:47:23.213885980Z   field required (type=value_error.missing)
2024-02-21T23:47:23.213888140Z author_orcid
2024-02-21T23:47:23.213890200Z   field required (type=value_error.missing)
2024-02-21T23:47:23.213892400Z created
2024-02-21T23:47:23.213894490Z   field required (type=value_error.missing)

I believe the root of the issue is that this attempt to convert a SubmissionMetadata object to a dict returns an empty dict (except for some SQLAlchemy metadata): https://github.com/microbiomedata/nmdc-server/blob/806c82479eb384cf0972b538e2b02fabc2a61518/nmdc_server/api.py#L637

Introduced in https://github.com/microbiomedata/nmdc-server/pull/1132

mslarae13 commented 8 months ago

@ssarrafan can we talk about this at infrastructure sync

naglepuff commented 8 months ago

I'm going to take a look at this now. It looks like creating a new submission has similar issues. I did not see this locally during development.

First I'm going to take a dump of dev postgres (I think we keep backups of dev) and restore locally, and see if I can spot the issue.

naglepuff commented 8 months ago

First I'm going to take a dump of dev postgres (I think we keep backups of dev) and restore locally, and see if I can spot the issue.

I don't see any backups for dev, so I grabbed the prod backup from this morning (2024-02-22). I was able to restore it with ~75 submissions and migrate it so that its on the same version as dev.

naglepuff commented 8 months ago

I'm able to recreate the issue locally. So far I've restored the backup, as previously mentioned, and set my current user as an "admin."

naglepuff commented 8 months ago

It looks like using **submission.__dict__ is unreliable, so my proposed solution will be to pass explicit parameters to the constructor.