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

Using wildcard in "put-metadata" header for PATCH / MergeThing command adds the metadata also for non-affected fields #1790

Open
thjaeckle opened this issue Oct 31, 2023 · 4 comments
Labels

Comments

@thjaeckle
Copy link
Member

When e.g. using the following put-metadata header:

[{"key":"*/createdAt","value": "now!"}]

On a HTTP request:

PATCH /api/2/things/my:thing-1

E.g. sending the payload:

{
  "attributes": {
    "only-one": 2
  }
}

Will also lead to all existing fields in the Thing getting the metadata, e.g. as in:

{
  "_metadata": {
    "thingId": {
        "createdAt": "now!"
    },
    "policyId": {
        "createdAt": "now!"
    },
    "attributes": {
        "only-one": {
            "createdAt": "now!"
        }
    }
  }
}

That is unexpected and should instead only modify the metadata of the provided fields to "PATCH".

@thjaeckle thjaeckle added the bug label Oct 31, 2023
@sejal-bansal
Copy link

@thjaeckle I would like to work on this issue. Could you please assign it to me?

@thjaeckle
Copy link
Member Author

@sejal-bansal cool, thanks
This however is probably not trivial to fix, I would assume.

@thjaeckle
Copy link
Member Author

@sejal-bansal any update here? Do you work on this or shall I unassign the issue again?

@kulta4
Copy link

kulta4 commented May 8, 2024

Hi @thjaeckle, @sejal-bansal!
I tried UpdateTwinWithLiveResponse mapper, [{"key":"/updated-via","value":"device-live-response"}] in put-metadata. I am facing error "message": "The wildcard expression '//updated-via' in header 'put-metadata' is not valid.",
how to fix this and I want to get the detailed implementation to achieve this in doc i have seen {
"dittoHeadersForMerge": {
"if-match": "",
"response-required": false,
"put-metadata": [
{"key":"
/updated-by","value":"{{ request:subjectId }}"},
{"key":"/updated-via","value":"device-live-response"},
{"key":"
/update-hint","value":"{{ header:some-custom-hint }}"},
{"key":"*/updated-at","value":"{{ time:now }}"}
]
}
} this much config example was there. can anyone help to do this properly

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

No branches or pull requests

3 participants