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

docs(website): fix incorrect example about the contains function #22499

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

seunghunee
Copy link
Contributor

@seunghunee seunghunee commented Feb 24, 2025

Summary

The contains function is now infallible and always returns a boolean value.
This commit fixes the incorrect example in the transformation guide.

Change Type

  • Bug fix
  • New feature
  • Non-functional (chore, refactoring, docs)
  • Performance

Is this a breaking change?

  • Yes
  • No

How did you test this PR?

Does this PR include user facing changes?

  • Yes. Please add a changelog fragment based on our guidelines.
  • No. A maintainer will apply the "no-changelog" label to this PR.

Checklist

  • Please read our Vector contributor resources.
    • make check-all is a good command to run locally. This check is
      defined here. Some of these
      checks might not be relevant to your PR. For Rust changes, at the very least you should run:
      • cargo fmt --all
      • cargo clippy --workspace --all-targets -- -D warnings
      • cargo nextest run --workspace (alternatively, you can run cargo test --all)
  • If this PR introduces changes Vector dependencies (modifies Cargo.lock), please
    run dd-rust-license-tool write to regenerate the license inventory and commit the changes (if any). More details here.

References

The `contains` function is now infallible and always returns a boolean value.
This commit fixes the example in the `transformation` guide.
@seunghunee seunghunee requested review from a team as code owners February 24, 2025 15:07
@bits-bot
Copy link

bits-bot commented Feb 24, 2025

CLA assistant check
All committers have signed the CLA.

Copy link
Member

@pront pront left a comment

Choose a reason for hiding this comment

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

Thanks @seunghunee, will merge once the CLA is signed.

@pront pront self-assigned this Feb 24, 2025
@domalessi domalessi self-assigned this Feb 24, 2025
@pront pront enabled auto-merge February 24, 2025 21:40
@pront pront added the no-changelog Changes in this PR do not need user-facing explanations in the release changelog label Feb 24, 2025
@@ -138,8 +138,8 @@ transforms:
# If the log message contains the phrase "Great Scott!", set the new field
# "critical" to true, otherwise set it to false. If the "contains" function
# errors, log the error (instead of aborting the script, as above).
if (is_critical, err = contains(.message, "Great Scott!"); err != null) {
log(err, level: "error")
if (is_critical = contains(.message, "Great Scott!"); is_critical) {
Copy link
Member

Choose a reason for hiding this comment

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

Hm, took another look. This is still a fallible assignment per: playground

What we want instead is:

is_critical = contains(string!(.message), "Great Scott!")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Changes in this PR do not need user-facing explanations in the release changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants