Skip to content
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

Submit metadata after creating by tag assignment fails #1883

Open
1 task done
ebroda opened this issue Oct 1, 2024 · 2 comments · May be fixed by #1906
Open
1 task done

Submit metadata after creating by tag assignment fails #1883

ebroda opened this issue Oct 1, 2024 · 2 comments · May be fixed by #1906
Labels

Comments

@ebroda
Copy link
Contributor

ebroda commented Oct 1, 2024

Description of the issue

Follow up of #1882

If you fixed the editor, as shown in #1882, and now want to submit changes you made, this fails with an javascript alert saing "Bad request".

Steps to Reproduce

  1. Follow setup of Adding a tag to a table without metadata, breaks metadata editor #1882 and apply change to js as described there.
  2. Now set some attributes and submit the form.
  3. Get a 400 error.

Ideas of solution

So it does a POST request on http://localhost:8000/api/v0/schema/model_draft/tables/test_with_tag/meta/ and this returns even a message:

Metadata could not be parsed: 'list' object has no attribute 'get'

Unfortunately, the exception is not providing any more context, like what object is problematic and so on.

But with forcing the oep to simply drop the execption unchanged to get the stack trace, we can get at least closer to it.

So looks like this line with Context foreignKeys.

https://github.com/OpenEnergyPlatform/omi/blob/8b3aa4c/src/omi/dialects/oep/parser.py#L1152-L1162

....
    metadata, error = actions.try_parse_metadata(raw_input)
  File "/home/me/OEP/api/actions.py", line 216, in try_parse_metadata
    return parser.parse(inp), None
  File "/home/me/OEP/oep-venv/lib/python3.10/site-packages/omi/dialects/base/dialect.py", line 44, in parse
    return p.parse_from_string(string, *args, **kwargs)
  File "/home/me/OEP/oep-venv/lib/python3.10/site-packages/omi/dialects/oep/parser.py", line 823, in parse_from_string
    return self.parse(
  File "/home/me/OEP/oep-venv/lib/python3.10/site-packages/omi/dialects/oep/parser.py", line 1161, in parse
    source_fields = [
  File "/home/me/OEP/oep-venv/lib/python3.10/site-packages/omi/dialects/oep/parser.py", line 1162, in <listcomp>
    field_dict[field_name]
KeyError: None

Just for the sake of completeness, here's the json structure that was send (only formatted, else directly from the post request):
post_data.json

Concrete problem here is now:

"foreignKeys":[{"fields":[null]

Null, which become None in Python, seems to be here the problem. If that is updated to an empty list, the query basically works, but another exception occurs:

Metadata could not be compiled: 'JSONCompiler' object has no attribute 'compile'

And here is ends for me.

So easiest solution is probably to get back to #1882 to avoid producing invalid meta JSON structure.

Context and Environment

  • Version used: develop
  • Operating system: -
  • Environment setup and (python) version: -

Workflow checklist

@ebroda ebroda added the bug label Oct 1, 2024
@jh-RLI
Copy link
Contributor

jh-RLI commented Nov 20, 2024

Once we finally migrated to oemetadata v2 and omi v1 this will become more stable. The current metadata validation was reworked. Afterward, the parsing will work correctly & will provide better error msg...

I will also look into fixing the issue above.

jh-RLI added a commit that referenced this issue Nov 21, 2024
@jh-RLI
Copy link
Contributor

jh-RLI commented Nov 21, 2024

Well since this error will resolve anyway once we implemented the new metadata and omi version, i just implemented a bit of a hack to fix this. I just catch the FK field property in the recursive JavaScript function ... I will revise this code and make it more robust soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants