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

Attempting to a insert nested key path can stomp on an existing value. #956

Open
beelsebob opened this issue Feb 8, 2025 · 1 comment
Open
Labels
bug Something isn't working

Comments

@beelsebob
Copy link

What happened

For some key paths, inserting a value can stomp on an existing value in the database.

Client

Other

Browser

Other or N/A

How to reproduce

  1. Send the request wget http://<moonraker>/server/database/item --header='Content-Type:application/json' --post-data='{"namespace": "test", "key": "a", "value": 1}'
  2. Send the request wget http://<moonraker>/server/database/item --header='Content-Type:application/json' --post-data='{"namespace": "test", "key": "a.b", "value": 2}'

Expected Results:
A 400 response, with the message "Item at key 'a' in namespace 'test' is not a dictionary object, cannot insert."

This happens correctly if you attempt to insert a.b.c after inserting a.b.

Actual Results:
a 200 response, a is replaced in the database with the value { "b" : 2 } instead of 1.

Additional information

No response

@beelsebob beelsebob added the bug Something isn't working label Feb 8, 2025
@Arksine
Copy link
Owner

Arksine commented Feb 9, 2025

Thanks. Please attach moonraker.log to bug reports reproducing the issue.

This is the anticipated behavior. If you check the log, you'll likely see an entry stating it detected the wrong type for the top level entry and its overwriting it. That said, I can see how this is inconsistent with the behavior of nested keys.

I'll need to think on this. What I don't want to do is change the behavior and break existing clients that presume an insert operation will overwrite the top level key. I could change the behavior of nested keys to overwrite the existing value with a dict.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants