-
Notifications
You must be signed in to change notification settings - Fork 54
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
JsonTransform transforms template #263
Comments
Tried to create a PR to fix this issue, but for some reason either GitHub or this project will not allow me to push my branch. Anyway, a simple fix would be to change the method at line 106 of
Yes, this would break things that depend on the flawed behaviour, but I can't imagine any scenario where that behaviour is desirable... but then I can't imagine how this would not have been caught and fixed earlier. There may be better solutions, such as preventing the mutation somewhere else. |
Transformer object is used to execute the transformation, only if transformer and input are strings this doesn't happen (transformer string is converter into an object/array). |
@Courela, Is it meant only as an observation that the other methods which take and transform strings to objects work as expected? It is only when we directly call this public method that we should expect the problem (and it is useful and therefore desirable that this method should be public). |
It's just an observation on how it works. For creating a PR you must fork this project, commit your changes there and then do a cross-fork PR on this project. |
@Courela, why a fork instead of a simple branch? I'll try to find time to look at this within the next couple weeks but since I have a work-around, it's not high priority for me at the moment. |
I don't know, I started to make PRs this way, I'm not the owner of the project, I just started using it and try to improve it. |
I finally made a PR for this: |
We are using JUST templates to transform messages coming out of Salesforce to abstractions which better suit our business needs and mask the Salesforce implementation details. There is a lot of abstraction within this process so we don't need to hardcode either the input or output models nor even the transformations as we can store JUST templates in a Mongo database.
When dealing with Salesforce, one must bulkify everything (which is probably a good rule of thumb for most development), which exposes a bug in how
JUST.Transform(JObject transformer, JToken input)
seems to be working.I can execute this method:
and the output is correct.
However, when multiple messages are processed, only the first message is correct and the rest are identical to the first.
Inspecting with the debugger reveals that when
_jsonTransformer.Transform(settings.JustTemplate, jsonPayload)
is executed, the value ofsettings.JustTemplate
is modified such that all subsequent invocations will receive the same value.We should be able to fix this in by cloning the value of
settings.JustTemplate
before consuming a clone of it.The text was updated successfully, but these errors were encountered: