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

bug: #1426

Open
phorward opened this issue Feb 25, 2025 · 0 comments · May be fixed by #1427
Open

bug: #1426

phorward opened this issue Feb 25, 2025 · 0 comments · May be fixed by #1427
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability help wanted Extra attention is needed

Comments

@phorward
Copy link
Member

ViUR currently is not able to handle RecordBones in RecordBones.

[2025-02-25 14:01:02,112] /.../viur/core/request.py:375 [ERROR] ViUR has caught an unhandled exception!
[2025-02-25 14:01:02,112] /.../viur/core/request.py:376 [ERROR] Read something from the datastore thats not a dict: <class 'viur.core.skeleton.SkeletonInstance'> <SkeletonInstance of subBoneRelation with {'subbone_name': 'blub'}> subrel
Traceback (most recent call last):
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/request.py", line 350, in _process
    self._route(path)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/request.py", line 625, in _route
    res = caller(*self.args, **kwargs)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/module.py", line 315, in __call__
    return self._func(self._instance, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/prototypes/list.py", line 280, in add
    skel.write()
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/skeleton.py", line 1460, in write
    bone.postSavedHandler(skel, bone_name, key)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/record.py", line 112, in postSavedHandler
    bone.postSavedHandler(using, bone_name, None)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/record.py", line 108, in postSavedHandler
    for idx, lang, value in self.iter_bone_value(skel, boneName):
                            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/base.py", line 1385, in iter_bone_value
    value = skel[name]
            ~~~~^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/skeleton.py", line 264, in __getitem__
    boneInstance.unserialize(self, key)
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/base.py", line 968, in unserialize
    res = self.singleValueUnserialize(loadVal)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "~/myproject/.venv/lib/python3.12/site-packages/viur/core/bones/record.py", line 67, in singleValueUnserialize
    assert isinstance(value, dict), f"Read something from the datastore thats not a dict: {type(value)} {value!r} {self.name}"
           ^^^^^^^^^^^^^^^^^^^^^^^
AssertionError: Read something from the datastore thats not a dict: <class 'viur.core.skeleton.SkeletonInstance'> <SkeletonInstance of subBoneRelation with {'subbone_name': 'blub'}> subrel

skeletons/test.py:

class subBoneRelation(RelSkel):
    subbone_name = StringBone(descr="name")


class simpleBoneRelation(RelSkel):
    relbone_name = StringBone(descr="name")
    subrel = RecordBone(
        descr="simple record bone",
        format="$(dest.name): $(dest.record_select)",
        using=subBoneRelation
    )


class RecTestSkel(Skeleton):
    name = StringBone(
        descr="Name",
        required=True,
    )

    simple_record = RecordBone(
        descr="simple record bone",
        format="$(dest.name): $(dest.record_select)",
        using=simpleBoneRelation
    )

modules/test.py:

from viur.core.prototypes import List


class RecTest(List):
    pass
@phorward phorward added bug(fix) Something isn't working or address a specific issue or vulnerability help wanted Extra attention is needed labels Feb 25, 2025
@phorward phorward added this to the ViUR-core v3.7 milestone Feb 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug(fix) Something isn't working or address a specific issue or vulnerability help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant