Skip to content

Conversation

ztonny
Copy link
Contributor

@ztonny ztonny commented Sep 11, 2025

in some cases, err.Error() will be called when err is nil, fix it;

What problem does this PR solve?

Issue Number: close #439

Related PR: #xxx

Problem Summary:

Release note

None

Check List (For Author)

  • Test

    • Regression test
    • Unit Test
    • Manual test (add detailed scripts or steps below)
    • No need to test or manual test. Explain why:
      • This is a refactor/code format and no logic has been changed.
      • Previous test can cover this change.
      • No code files have been changed.
      • Other reason
  • Behavior changed:

    • No.
    • Yes.
  • Does this need documentation?

    • No.
    • Yes.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

in some cases, err.Error() will be called when err is nil, fix it;
if _, ok := m[COMPUTE_GROUP_ID]; !ok {
klog.Errorf("GetBackendsByComputeGroupId backends tag get compute_group_name failed, tag: %s, err: %s\n", be.Tag, err.Error())
return nil, err
return nil, fmt.Errorf("GetBackendsByComputeGroupId backends tag get compute_group_name failed, tag: %s, err: no compute_group_id field found", be.Tag)
Copy link
Contributor

Choose a reason for hiding this comment

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

'klog.Errorf' needs to print the error log, here you need to keep using this method to print this error log

m, err := ResolveConfigMaps(tests, dorisv1.Component_FE)
if err != nil || len(m) == 0 {
t.Errorf("resolve configmaps faild, len=%d, err=%s", len(m), err.Error())
t.Errorf("resolve configmaps faild, len=%d, err=%#v", len(m), err)
Copy link
Contributor

Choose a reason for hiding this comment

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

Try not to use %#v to print structure instances. This may cause err null pointer problems and require post-processing after checking for null.

Copy link
Contributor

@catpineapple catpineapple left a comment

Choose a reason for hiding this comment

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

Please check it

use klog to print log message and drop %#v for err;
use klog to print log message
use klog to print log message and drop %#v for err;
Copy link
Contributor

@catpineapple catpineapple left a comment

Choose a reason for hiding this comment

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

LGTM

@catpineapple catpineapple merged commit 09aca41 into apache:master Sep 18, 2025
1 check passed
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.

[Bug] in some cases, err.Error() will be called when err is nil in fact, this will cause nil pointer panic

2 participants