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

Fix incorrect useage of charlist #179

Merged
merged 3 commits into from
Jan 1, 2025
Merged

Conversation

davydog187
Copy link
Contributor

Single quotes (charlists) were used instead of double quotes (binaries).

Single quotes (charlists) were used instead of double quotes (binaries).
optional(:tls_required) => boolean(),
optional(:auth_required) => boolean(),
}
:client_id => non_neg_integer(),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like my formatter changed this as well. If you'd like, I can split this out into a different PR

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought I had a formatter check built into the CI process, but maybe I'm misremembering. If this is the standard formatter settings for current elixir versions then we should just apply it now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH i'm not sure where the difference is coming from

@mmmries
Copy link
Collaborator

mmmries commented Dec 14, 2024

Hey @davydog187 thanks for opening a PR ❤️ 💛 💙 💚 💜

Most of these arguments do (or at least did) have a requirement to be passed a charlists because they are passthrough arguments to erlang stdlib functions (opening a TLS or TCP socket). Did you test passing in strings/binaries? Maybe the erlang functions have started to support strings?

I'm definitely open to updating the docs and improving typespecs if the underlying functions support this. It's definitely more idiomatic for Elixir libraries

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@davydog187
Copy link
Contributor Author

Cleaning up now, sorry @mmmries I was moving too fast 😅

@davydog187
Copy link
Contributor Author

davydog187 commented Dec 30, 2024

@mmmries regarding the question of binaries vs charlists, :gen_tcp still expects a charlist https://www.erlang.org/doc/apps/kernel/inet#t:hostname/0, but Gnat.Handshake.connect/1 always converts it to a charlist

https://github.com/nats-io/nats.ex/blob/v1.9.0/lib/gnat/handshake.ex#L10

Technically it is correct to pass a a binary or a charlist, but the typespecs only specify binary(). I can specify both, but IMO we should keep it as is.

@davydog187
Copy link
Contributor Author

Should be good to run CI now @mmmries

@mmmries mmmries merged commit 3635276 into nats-io:main Jan 1, 2025
3 checks passed
@mmmries
Copy link
Collaborator

mmmries commented Jan 1, 2025

Double thanks for taking a second pass and confirming the details on the binary vs charlists. Appreciate the contribution

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants