Skip to content
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

[erlang-server] Dialyzer spec #9983

Merged
merged 2 commits into from
Jul 24, 2021
Merged

Conversation

sebastiw
Copy link
Contributor

@sebastiw sebastiw commented Jul 20, 2021

Dialyzer fails with success typing after #9946
Line 29 Column 2: Invalid type specification for function .._handler:init/2. The success typing is ...

@tsloughter @jfacorro @robertoaloi

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master, 5.3.x, 6.0.x
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@wing328
Copy link
Member

wing328 commented Jul 20, 2021

@sebastiw thanks for the PR.

cc @lixen-wg2 as well.

@wing328 wing328 added Client: Erlang Enhancement: Code format Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc. and removed Enhancement: Code format labels Jul 20, 2021
@wing328
Copy link
Member

wing328 commented Jul 21, 2021

Line 29 Column 2: Invalid type specification for function .._handler:init/2. The success typing is ...

@sebastiw do you mind sharing the exact command to reproduce the above?

@wing328 wing328 added this to the 5.2.1 milestone Jul 21, 2021
@sebastiw
Copy link
Contributor Author

sure rebar3 dialyzer should do it

@wing328
Copy link
Member

wing328 commented Jul 21, 2021

@sebastiw thanks for the command but I couldn't repeat it locally in my Mac:

src/petstore_pet_api.erl
  17: Function add_pet/2 has no local return
  21: Function add_pet/3 has no local return
  38: Function delete_pet/2 has no local return
  42: Function delete_pet/3 has no local return
  59: Function find_pets_by_status/2 has no local return
  63: Function find_pets_by_status/3 has no local return
  80: Function find_pets_by_tags/2 has no local return
  84: Function find_pets_by_tags/3 has no local return
 101: Function get_pet_by_id/2 has no local return
 105: Function get_pet_by_id/3 has no local return
 122: Function update_pet/2 has no local return
 126: Function update_pet/3 has no local return
 143: Function update_pet_with_form/2 has no local return
 147: Function update_pet_with_form/3 has no local return
 164: Function upload_file/2 has no local return
 168: Function upload_file/3 has no local return

src/petstore_store_api.erl
  13: Function delete_order/2 has no local return
  17: Function delete_order/3 has no local return
  34: Function get_inventory/1 has no local return
  38: Function get_inventory/2 has no local return
  55: Function get_order_by_id/2 has no local return
  59: Function get_order_by_id/3 has no local return
  76: Function place_order/2 has no local return
  80: Function place_order/3 has no local return

src/petstore_user_api.erl
  17: Function create_user/2 has no local return
  21: Function create_user/3 has no local return
  38: Function create_users_with_array_input/2 has no local return
  42: Function create_users_with_array_input/3 has no local return
  59: Function create_users_with_list_input/2 has no local return
  63: Function create_users_with_list_input/3 has no local return
  80: Function delete_user/2 has no local return
  84: Function delete_user/3 has no local return
 101: Function get_user_by_name/2 has no local return
 105: Function get_user_by_name/3 has no local return
 122: Function login_user/3 has no local return
 126: Function login_user/4 has no local return
 143: Function logout_user/1 has no local return
 147: Function logout_user/2 has no local return
 164: Function update_user/3 has no local return
 168: Function update_user/4 has no local return
===> Warnings written to _build/default/23.2.5.dialyzer_warnings
===> Warnings occurred running dialyzer: 40

I don't see similar warnings. Are you seeing something similar to the above in your end?

@sebastiw
Copy link
Contributor Author

'no local return' actually means that the type checker expect that function to crash (no return from local context)
this hide other type faults

@sebastiw
Copy link
Contributor Author

I'll check in a bit when I've got my computer.

@sebastiw
Copy link
Contributor Author

ok here goes

% pwd
/home/seba/work/forks/openapi-generator/samples/server/petstore/erlang-server
% git log --oneline -1 | cat
e20ccd49ed4 9955 dart-dio-next only remove typed_data import if safe (#9956)
% rebar3 version
rebar 3.16.1 on Erlang/OTP 24 Erts 12.0.1
% rebar3 dialyzer
===> Verifying dependencies...
===> Fetching cowboy (from {git,"https://github.com/ninenines/cowboy.git",
                  {ref,"3eec447960eb03cde48f0f04cd72fd4d1e548ca0"}})
===> Fetching jesse (from {git,"https://github.com/for-GET/jesse.git",
                 {ref,"cfb1b3edd1cbb4cad284001ba4771554aa6a7df5"}})
===> Fetching jsx (from {git,"https://github.com/talentdeficit/jsx.git",
               {ref,"bb9b3e570a7efe331eed0900c3a5188043a850d7"}})
===> Fetching rfc3339 (from {git,"https://github.com/talentdeficit/rfc3339.git",
                   {ref,"31716adecb4b405b1f5ef80b9f3fa50f39b26af8"}})
===> Fetching cowlib (from {git,"https://github.com/ninenines/cowlib",
                  {ref,"1b5539a1da1d39b110d81b118000f00bbedaf4b4"}})
===> Fetching ranch (from {git,"https://github.com/ninenines/ranch",
                 {ref,"3190aef88aea04d6dce8545fe9b4574288903f44"}})
===> Analyzing applications...
===> Compiling rfc3339
===> Compiling jsx
===> Compiling jesse
===> Compiling cowlib
===> Compiling ranch
_build/default/lib/ranch/src/ranch_ssl.erl:142:7: Warning: ssl:ssl_accept/3 is removed; use ssl_handshake/1,2,3 instead

===> Compiling cowboy
===> Analyzing applications...
===> Compiling openapi
===> Dialyzer starting, this may take a while...
===> Add debug_info to compiler options (erl_opts) if Dialyzer fails to load Core Erlang.
===> Updating plt...
===> Resolving files...
===> Updating base plt...
===> Resolving files...
===> Checking 204 files in ../../../../../../.cache/rebar3/rebar3_24.0.1_plt...
===> Copying ../../../../../../.cache/rebar3/rebar3_24.0.1_plt to _build/default/rebar3_24.0.1_plt...
===> Checking 204 files in _build/default/rebar3_24.0.1_plt...
===> Adding 176 files to _build/default/rebar3_24.0.1_plt...
===> Doing success typing analysis...
===> Resolving files...
===> Analyzing 10 files with _build/default/rebar3_24.0.1_plt...

src/openapi_pet_handler.erl
Line 29 Column 2: Invalid type specification for function openapi_pet_handler:init/2. The success typing is (#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[{_,_}]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [neg_integer() | {_,_}]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [atom() | [any()] | char()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},{map(),atom(),atom()}) -> {'cowboy_rest',#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[any()]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [any()]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [any()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(any(),binary() | [])=>binary() | maybe_improper_list(any(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},#state{operation_id::atom(),logic_handler::atom(),validator_state::jesse_state:state(),context::#{}}}

src/openapi_store_handler.erl
Line 29 Column 2: Invalid type specification for function openapi_store_handler:init/2. The success typing is (#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[{_,_}]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [neg_integer() | {_,_}]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [atom() | [any()] | char()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},{map(),atom(),atom()}) -> {'cowboy_rest',#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[any()]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [any()]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [any()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(any(),binary() | [])=>binary() | maybe_improper_list(any(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},#state{operation_id::atom(),logic_handler::atom(),validator_state::jesse_state:state(),context::#{}}}

src/openapi_user_handler.erl
Line 29 Column 2: Invalid type specification for function openapi_user_handler:init/2. The success typing is (#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{byte(),byte(),byte(),byte()} | {char(),char(),char(),char(),char(),char(),char(),char()},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[{_,_}]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [neg_integer() | {_,_}]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [atom() | [any()] | char()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},{map(),atom(),atom()}) -> {'cowboy_rest',#{'body_length':='undefined' | non_neg_integer(), 'cert':='undefined' | binary(), 'has_body':=boolean(), 'headers':=#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'host':=binary(), 'method':=binary(), 'path':=binary(), 'peer':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'pid':=pid(), 'port':=char(), 'qs':=binary(), 'ref':=_, 'scheme':=binary(), 'sock':={{_,_,_,_} | {_,_,_,_,_,_,_,_},char()}, 'streamid':=_, 'version':=atom(), 'bindings'=>#{atom()=>_}, 'charset'=>'undefined' | binary(), 'has_read_body'=>'true', 'has_sent_resp'=>'headers' | 'true', 'host_info'=>[binary()], 'language'=>'undefined' | binary(), 'media_type'=>{binary(),binary(),[any()]}, 'multipart'=>'done' | {binary(),binary()}, 'path_info'=>[binary()], 'range'=>{binary(),binary() | [any()]}, 'resp_body'=>binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []) | {'sendfile',non_neg_integer(),non_neg_integer(),atom() | binary() | [any()]}, 'resp_cookies'=>#{binary() | maybe_improper_list(any(),binary() | [])=>binary() | maybe_improper_list(any(),binary() | [])}, 'resp_headers'=>#{binary()=>binary() | maybe_improper_list(any(),binary() | [])}, 'websocket_version'=>7 | 8 | 13, _=>_},#state{operation_id::atom(),logic_handler::atom(),validator_state::jesse_state:state(),context::#{}}}
===> Warnings written to _build/default/24.0.1.dialyzer_warnings
===> Warnings occurred running dialyzer: 3
% git checkout fix-validator-spec
% rm -rf _build
% rebar3 dialyzer
===> Verifying dependencies...
===> Fetching cowboy (from {git,"https://github.com/ninenines/cowboy.git",
                  {ref,"3eec447960eb03cde48f0f04cd72fd4d1e548ca0"}})
===> Fetching jesse (from {git,"https://github.com/for-GET/jesse.git",
                 {ref,"cfb1b3edd1cbb4cad284001ba4771554aa6a7df5"}})
===> Fetching jsx (from {git,"https://github.com/talentdeficit/jsx.git",
               {ref,"bb9b3e570a7efe331eed0900c3a5188043a850d7"}})
===> Fetching rfc3339 (from {git,"https://github.com/talentdeficit/rfc3339.git",
                   {ref,"31716adecb4b405b1f5ef80b9f3fa50f39b26af8"}})
===> Fetching cowlib (from {git,"https://github.com/ninenines/cowlib",
                  {ref,"1b5539a1da1d39b110d81b118000f00bbedaf4b4"}})
===> Fetching ranch (from {git,"https://github.com/ninenines/ranch",
                 {ref,"3190aef88aea04d6dce8545fe9b4574288903f44"}})
===> Analyzing applications...
===> Compiling rfc3339
===> Compiling jsx
===> Compiling jesse
===> Compiling cowlib
===> Compiling ranch
_build/default/lib/ranch/src/ranch_ssl.erl:142:7: Warning: ssl:ssl_accept/3 is removed; use ssl_handshake/1,2,3 instead

===> Compiling cowboy
===> Analyzing applications...
===> Compiling openapi
===> Dialyzer starting, this may take a while...
===> Add debug_info to compiler options (erl_opts) if Dialyzer fails to load Core Erlang.
===> Updating plt...
===> Resolving files...
===> Updating base plt...
===> Resolving files...
===> Checking 204 files in ../../../../../../.cache/rebar3/rebar3_24.0.1_plt...
===> Copying ../../../../../../.cache/rebar3/rebar3_24.0.1_plt to _build/default/rebar3_24.0.1_plt...
===> Checking 204 files in _build/default/rebar3_24.0.1_plt...
===> Adding 176 files to _build/default/rebar3_24.0.1_plt...
===> Doing success typing analysis...
===> Resolving files...
===> Analyzing 10 files with _build/default/rebar3_24.0.1_plt...

@wing328
Copy link
Member

wing328 commented Jul 24, 2021

Thanks for the info. I'm able to repeat it. Will use it to verify erlang-related changes moving forward.

@wing328 wing328 merged commit 888f9cd into OpenAPITools:master Jul 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client: Erlang Enhancement: Code Cleanup General refactoring, removal of deprecated things, commenting, etc.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants