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

public_key:cacerts_load/0 may return 'undefined', violating its function spec #8604

Closed
alco opened this issue Jun 21, 2024 · 0 comments
Closed
Assignees
Labels
bug Issue is reported as a bug stalled waiting for input by the Erlang/OTP team team:PS Assigned to OTP team PS

Comments

@alco
Copy link

alco commented Jun 21, 2024

Describe the bug
The function call public_key:cacerts_load() may return undefined if it does not find certificates at default OS locations. This is by design as can be seen in the source code.

However, the spec of the function only mentions ok and {error, term()} as two possible return types.

To Reproduce
The easiest way to reproduce this is to run Erlang in Docker using one of the -slim variants:

$ docker run --rm -it erlang:27.0-slim
Erlang/OTP 27 [erts-15.0] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V15.0 (press Ctrl+G to abort, type help(). for help)
1> public_key:cacerts_load().
undefined
$ docker run --rm -it erlang:26.2.5-slim
Erlang/OTP 26 [erts-14.2.5] [source] [64-bit] [smp:16:16] [ds:16:16:10] [async-threads:1] [jit:ns]

Eshell V14.2.5 (press Ctrl+G to abort, type help(). for help)
1> public_key:cacerts_load().
undefined

Expected behavior
I would expect the function to return {error, not_found} or similar so that the return value matches the return type specified in the function spec.

Affected versions
It looks like the undefined return value was first introduced in OTP 26.2 - bc28c90.

@alco alco added the bug Issue is reported as a bug label Jun 21, 2024
@IngelaAndin IngelaAndin added the team:PS Assigned to OTP team PS label Jun 22, 2024
@IngelaAndin IngelaAndin added the stalled waiting for input by the Erlang/OTP team label Jul 11, 2024
dgud added a commit that referenced this issue Aug 16, 2024
…o maint

* dgud/public_key/fix-error-reason/GH-8604/OTP-19183:
  Improve error handling
@dgud dgud closed this as completed Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue is reported as a bug stalled waiting for input by the Erlang/OTP team team:PS Assigned to OTP team PS
Projects
None yet
Development

No branches or pull requests

3 participants