node: Fix non-informative message when parse node attributes #475

Merged
fyrchik merged 1 commit from acid-ant/frostfs-node:bugfix/455-fix-logs into master 2023-06-28 15:02:31 +00:00

View file

@ -1,7 +1,6 @@
package attributes
import (
"errors"
"fmt"
"strings"
@ -21,7 +20,7 @@ func ReadNodeAttributes(dst *netmap.NodeInfo, attrs []string) error {
k, v, found := strings.Cut(line, keyValueSeparator)
if !found {
return errors.New("missing attribute key and/or value")
return fmt.Errorf("wrong format for node attribute: '%s'", attrs[i])
fyrchik marked this conversation as resolved Outdated

s/attribute/node attribute/ ? To be consistent with the errors below.

s/attribute/node attribute/ ? To be consistent with the errors below.

Fixed.

Fixed.
}
_, ok := cache[k]
@ -36,9 +35,9 @@ func ReadNodeAttributes(dst *netmap.NodeInfo, attrs []string) error {
v = replaceEscaping(v, true)
if k == "" {
return errors.New("empty key")
return fmt.Errorf("empty key in node attribute: '%s'", attrs[i])
fyrchik marked this conversation as resolved Outdated

To me empty key and empty value are OK, they just need a little more context (that these are key/value from a section node.attributes

To me `empty key` and `empty value` are OK, they just need a little more context (that these are key/value from a section `node.attributes`

Updated.

Updated.
} else if v == "" {
return errors.New("empty value")
return fmt.Errorf("empty value in node attribute: '%s'", attrs[i])
}
dst.SetAttribute(k, v)