Skip to content
This repository has been archived by the owner on Oct 10, 2023. It is now read-only.

Handle errors from regexp #200

Merged
merged 7 commits into from
May 4, 2023

Conversation

thepetk
Copy link
Collaborator

@thepetk thepetk commented May 4, 2023

What does this PR do?

Replaces the regexp.MustCompile with regexp.Compile in case we provide a var and not a fixed/hardcoded value. This way it ensures that we will be able to catch any errors from regexp.

Example Replace:

re, err := regexp.MustCompile(regex)

With:

re, err := regexp.Compile(regex)
if err != nil {
   return ""
}

Which issue(s) this PR fixes:

Fixes #199

Copy link
Collaborator

@yangcao77 yangcao77 left a comment

Choose a reason for hiding this comment

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

confirmed that the issue has been fixed with this change.
can we add any test cases for this issue?

@thepetk
Copy link
Collaborator Author

thepetk commented May 4, 2023

confirmed that the issue has been fixed with this change. can we add any test cases for this issue?

I want to add the same project which we have faced the issue.

@thepetk
Copy link
Collaborator Author

thepetk commented May 4, 2023

@yangcao77 I've added an extra test case in alizer-test-resources -> this PR and I have updated the already existing PR for tests update

So this way we can merge the current workaround which will unblock HAS and this specific test case will be added with the next merge.

@thepetk thepetk mentioned this pull request May 4, 2023
@yangcao77
Copy link
Collaborator

/lgtm

@openshift-ci openshift-ci bot added the lgtm label May 4, 2023
@thepetk thepetk merged commit c2b889a into redhat-developer:main May 4, 2023
6 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Alizer should ignore pointer when looking for regex match for port detection
2 participants