Skip to content

Commit

Permalink
config: add subj URI to config verification error
Browse files Browse the repository at this point in the history
Before this patch, it was quite difficult to determine, which URI in
config was unsuitable.
Now the subject URI is listed in the error body.

NO_DOC=bugfix

Part of #9644
  • Loading branch information
Lord-KA authored and Totktonada committed Apr 15, 2024
1 parent 4c81aba commit 54e9008
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
4 changes: 4 additions & 0 deletions changelogs/unreleased/gh-9644-verbose-uri-error.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
## bugfix/config

* Added a subject URI to the error that is thrown on configuration
verification (gh-9644).
2 changes: 1 addition & 1 deletion src/box/lua/config/instance_config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ local function validate_uri_field(has_login_field, used_to_connect)
if used_to_connect then
local ok, err = uri_is_suitable_to_connect(uri)
if not ok then
w.error(err)
w.error("bad URI %q: %s", data, err)
end
end
end
Expand Down
12 changes: 12 additions & 0 deletions test/config-luatest/instance_config_schema_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -531,62 +531,71 @@ for case_name, case in pairs({
advertise = {uri = '0.0.0.0:3301'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "0.0.0.0:3301"',
'INADDR_ANY (0.0.0.0) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv4_user = {
advertise = {uri = '0.0.0.0:3301', login = 'user'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "0.0.0.0:3301"',
'INADDR_ANY (0.0.0.0) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv4_user_pass = {
advertise = {uri = '0.0.0.0:3301', login = 'user', password = 'pass'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "0.0.0.0:3301"',
'INADDR_ANY (0.0.0.0) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv6 = {
advertise = {uri = '[::]:3301'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "[::]:3301"',
'in6addr_any (::) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv6_user = {
advertise = {uri = '[::]:3301', login = 'user'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "[::]:3301"',
'in6addr_any (::) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv6_user_pass = {
advertise = {uri = '[::]:3301', login = 'user', password = 'pass'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "[::]:3301"',
'in6addr_any (::) cannot be used to create a client socket',
}, ': '),
},
zero_port = {
advertise = {uri = 'localhost:0'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "localhost:0"',
'An URI with zero port cannot be used to create a client socket',
}, ': '),
},
zero_port_user = {
advertise = {uri = 'localhost:0', login = 'user'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "localhost:0"',
'An URI with zero port cannot be used to create a client socket',
}, ': '),
},
zero_port_user_pass = {
advertise = {uri = 'localhost:0', login = 'user', password = 'pass'},
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.%s.uri',
'bad URI "localhost:0"',
'An URI with zero port cannot be used to create a client socket',
}, ': '),
},
Expand Down Expand Up @@ -629,20 +638,23 @@ for case_name, case in pairs({
advertise = '0.0.0.0:3301',
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.client',
'bad URI "0.0.0.0:3301"',
'INADDR_ANY (0.0.0.0) cannot be used to create a client socket',
}, ': '),
},
inaddr_any_ipv6 = {
advertise = '[::]:3301',
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.client',
'bad URI "[::]:3301"',
'in6addr_any (::) cannot be used to create a client socket',
}, ': '),
},
zero_port = {
advertise = 'localhost:0',
exp_err_msg = table.concat({
'[instance_config] iproto.advertise.client',
'bad URI "localhost:0"',
'An URI with zero port cannot be used to create a client socket',
}, ': '),
},
Expand Down

0 comments on commit 54e9008

Please sign in to comment.