New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ip_port schema type crash #11077
fix: ip_port schema type crash #11077
Conversation
1f2e018
to
2daa6f1
Compare
e5675bf
to
1ffbc3f
Compare
045a3c0
to
4a0c490
Compare
8bb5267
to
54cb5cd
Compare
@@ -1758,7 +1758,7 @@ base_listener(Bind) -> | |||
)}, | |||
{"bind", | |||
sc( | |||
hoconsc:union([ip_port(), integer()]), | |||
ip_port(), | |||
#{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove integer: ip_port() also support setting as 1883
.
@@ -2418,21 +2418,21 @@ mk_duration(Desc, OverrideMeta) -> | |||
to_duration(Str) -> | |||
case hocon_postprocess:duration(Str) of | |||
I when is_integer(I) -> {ok, I}; | |||
_ -> {error, Str} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hocon 0.39.9 has fixed a issue: typerelf:from_string
conversion is not executed when value is integer emqx/hocon#259
In order to be compatible with the previous format.
%% {error, "1"} = hocon_postprocess:duration("1")
%% we should ensure:
to_duration("12") -> 12.
to_duration_s("12") -> 12s
to_duration_ms("12") -> 12ms
to_timeout_duration("12") -> 12
to_timeout_duration_ms("12") -> 12ms
to_timeout_duration_s("12") -> 12s
0b61a01
to
676623b
Compare
to_integer(Str) when is_list(Str) -> | ||
case string:to_integer(Str) of | ||
{Int, []} -> {ok, Int}; | ||
{Int, <<>>} -> {ok, Int}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have another function clause to_integer(Str) when is_binary(Str) -> ...
to make this case clause reachable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch, I will remove is_list
676623b
to
856de78
Compare
Pull Request Test Coverage Report for Build 5317265419
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Do we need a changelog entry for this one @zhongwencool ? |
|
Fixes : Return 500 crash when update bind as a bad port.
No crash log after this PR.
The
emqx_schema:ip_port()
is supportinteger()
format, so we remove the union type.emqx/hocon#259
Summary
🤖 Generated by Copilot at 1f2e018
This pull request standardizes the schema and validation of listener ports across different modules. It removes the possibility of using integers as ports and replaces it with the
ip_port()
type. It also refactors and adds some helper functions inemqx_schema.erl
.PR Checklist
Please convert it to a draft if any of the following conditions are not met. Reviewers may skip over until all the items are checked:
changes/{ce,ee}/(feat|perf|fix)-<PR-id>.en.md
filesChecklist for CI (.github/workflows) changes
changes/
dir for user-facing artifacts update