Skip to content

Conversation

@franciscovalentecastro
Copy link
Contributor

@franciscovalentecastro franciscovalentecastro commented Jul 22, 2025

Description

Currently "transformation tests" fail in the comparison when there is a tab character in any of the log fields because the Marshalling to YAML converts a tab to its "escape sequence" (\t) . Proposing the solution to compare want with the Marshalled -> Unmarshalled (standarized) version of got to avoid this.

Related issue

b/413410475

How has this been tested?

Checklist:

  • Unit tests
    • Unit tests do not apply.
    • Unit tests have been added/modified and passed for this PR.
  • Integration tests
    • Integration tests do not apply.
    • Integration tests have been added/modified and passed for this PR.
  • Documentation
    • This PR introduces no user visible changes.
    • This PR introduces user visible changes and the corresponding documentation change has been made.
  • Minor version bump
    • This PR introduces no new features.
    • This PR introduces new features, and there is a separate PR to bump the minor version since the last release already.
    • This PR bumps the version.

@franciscovalentecastro franciscovalentecastro force-pushed the fcovalente-fix-tabs-transformation-tests branch from 5ebaf4b to 8c211a2 Compare July 22, 2025 17:56
@franciscovalentecastro franciscovalentecastro changed the title [transformation_test] Compare want with standarizedGot to avoid issues with string literals. [transformation_test] Compare want with standarizedGot to avoid issues when comparing string literals. Jul 22, 2025
Copy link
Member

@quentinmit quentinmit left a comment

Choose a reason for hiding this comment

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

Where does the \t enter into it? got and want are both Go structures, not YAML, so if a tab is being serialized as \t in the YAML that shouldn't be visible once it's unmarshalled again

@franciscovalentecastro
Copy link
Contributor Author

franciscovalentecastro commented Jul 22, 2025

@quentinmit Been getting this transformation_test failures in #1985. It seems that when un-marshalling, the \t escape sequence is being compared directly to the tab character in the original got, so it is not being converted again to a "tab" character.

In my understanding, any other character that is converted to its espace sequence could potentially present this issue.

    map[string]any{
- 		"jsonPayload": map[string]any{
- 			"message": string(`2025-07-18 15:08:05.267 | 1:M 18 Jul 2025 19:08:05.267 *  	{ ts-duplicate-policy    :        block }`),
- 		},
+ 		"jsonPayload": map[string]any{
+ 			"message": string(`2025-07-18 15:08:05.267 | 1:M 18 Jul 2025 19:08:05.267 *  \t{ ts-duplicate-policy    :        block }`),
+ 		},
        "labels":    map[string]any{"logging.googleapis.com/instrumentation_source": string("agent.googleapis.com/redis")},
        "logName":   string("projects/my-project/logs/transformation_test"),
        "timestamp": string("now"),
    }

@franciscovalentecastro
Copy link
Contributor Author

Update : Upgrading github.com/goccy/go-yaml to version v1.18.0 fixes the issue. Closing this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants