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

fix: Fix injection logic for datetime and span #589

Merged
merged 1 commit into from
Nov 7, 2024

Conversation

alilleybrinker
Copy link
Collaborator

The previous implementation of JSON pointer injection for datetime and span data was incorrect. In the prior implementation, the datetime or span data needed to be provided as an object with two fields: field and data, where field specifies the type to convert the data field into. The correct implementation is to simply try converting into one, then the other, and to then fail if neither succeeds. They have completely distinct string representations, so there is not a possibility of confusable conversion into the wrong type with this approach.

In the future we can and should update this implementation to incorporate the JSON schema data on what type is intended. I believe confusion on the use of JSON schema here (which does use the field/data pattern described above, but in the schema not the actual data) was the source of the original mistaken implementation.

The previous implementation of JSON pointer injection for datetime and
span data was incorrect. In the prior implementation, the datetime or
span data needed to be provided as an object with two fields: `field`
and `data`, where `field` specifies the type to convert the `data`
field into. The correct implementation is to simply try converting
into one, then the other, and to then fail if neither succeeds. They
have completely distinct string representations, so there is not a
possibility of confusable conversion into the *wrong* type with this
approach.

In the future we can and should update this implementation to
incorporate the JSON schema data on what type is intended. I believe
confusion on the use of JSON schema here (which *does* use the
`field`/`data` pattern described above, but in the _schema_ not the
actual data) was the source of the original mistaken implementation.

Signed-off-by: Andrew Lilley Brinker <[email protected]>
@alilleybrinker alilleybrinker added the product: hc Relates to the core "hc" binary label Nov 7, 2024
@alilleybrinker alilleybrinker self-assigned this Nov 7, 2024
Copy link
Collaborator

@j-lanson j-lanson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@alilleybrinker alilleybrinker merged commit 9435799 into main Nov 7, 2024
9 checks passed
@alilleybrinker alilleybrinker deleted the alilleybrinker/json_pointer_string branch November 8, 2024 23:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product: hc Relates to the core "hc" binary
Projects
Status: Done
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants