nns: Mention domain in panic messages #98
No reviewers
Labels
No labels
P0
P1
P2
P3
good first issue
Infrastructure
blocked
bug
config
discussion
documentation
duplicate
enhancement
go
help wanted
internal
invalid
kludge
observability
perfomance
question
refactoring
wontfix
No milestone
No project
No assignees
5 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: TrueCloudLab/frostfs-contract#98
Loading…
Reference in a new issue
No description provided.
Delete branch "elebedeva/frostfs-contract:fix/nns-panic-message"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Close #92
Output after fix:
Signed-off-by: Ekaterina Lebedeva ekaterina.lebedeva@yadro.com
@ -222,3 +222,3 @@
fragments := splitAndCheck(name)
if fragments == nil {
panic("invalid domain name format")
panic(getDomainNamePanicMessage(name))
How about to panic inside
splitAndCheck
and remove this and bellowif
statements?fixed
@ -913,0 +914,4 @@
// getDomainNamePanicMessage returns panic message for invalid domain name containing
// mentioned domain name
func getDomainNamePanicMessage(name string) string {
msg := "invalid domain name format: '" + name + "'"
You check something in
splitAndCheck
and then perform similar checks here.They can diverge with time, so the message will cease reflecting the real error.
How about this:
splitAndCheck
returns nil we alwayspanic
.done
52bf87411c
toa6c20b344c
a6c20b344c
to4e2882394c
@ -739,0 +724,4 @@
func checkDomainNameLength(name string) {
l := len(name)
if l > maxDomainNameLength {
panic(getDomainNamePanicMessage(name, "domain name too long: got = "+std.Itoa(len(name), 10)+", max = "+std.Itoa(maxDomainNameLength, 10)))
len(name)
-->l
@ -739,0 +727,4 @@
panic(getDomainNamePanicMessage(name, "domain name too long: got = "+std.Itoa(len(name), 10)+", max = "+std.Itoa(maxDomainNameLength, 10)))
}
if l < minDomainNameLength {
panic(getDomainNamePanicMessage(name, "domain name too short: got = "+std.Itoa(len(name), 10)+", min = "+std.Itoa(minDomainNameLength, 10)))
len(name)
-->l
4e2882394c
tob8efeec81c
@ -913,0 +905,4 @@
// getDomainNamePanicMessage returns panic message for invalid domain name containing
// mentioned domain name
func getDomainNamePanicMessage(name string, problem string) string {
IMO a separate function is useless.
It takes space in the byte code, even though it is basically a string concatenation.
The compiler is not clever enough to inline even though
problem != ""
can be derived statically.How about removing this function and moving common string in the constant?
Agree, removed
getDomainNamePanicMessage()
and added the constantb8efeec81c
to439699236a
439699236a
tod70e971bd5
d70e971bd5
to49e5270f67