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

Tesla.Multipart.assert_part_value! doesn't allow valid stream #677

Open
ananthakumaran opened this issue May 31, 2024 · 3 comments
Open

Comments

@ananthakumaran
Copy link

  @spec assert_part_value!(any) :: :ok | no_return
  defp assert_part_value!(%maybe_stream{})
       when maybe_stream in [IO.Stream, File.Stream, Stream],
       do: :ok

The assert_part_value! function checks if the argument is a stream, but it only allows a subset of the valid streams. There is no restriction on what data type could be used to represent a stream

iex(1)> enum = 1001..9999
iex(2)> n = 3
iex(3)> stream = Stream.transform(1001..9999, 0, fn i, acc ->
...(3)>   if acc < n, do: {[i], acc + 1}, else: {:halt, acc}
...(3)> end)
#Function<60.29975488/2 in Stream.transform/3>

In the example above, stream is represented via a function. https://elixirforum.com/t/how-to-check-if-an-argument-is-a-stream-or-stream-like-function/50622

@yordis
Copy link
Member

yordis commented Oct 25, 2024

@teamon focusing on other stuff right now, I haven't touch anything related to streaming, any thoughts here?

@teamon
Copy link
Member

teamon commented Oct 25, 2024

I see two options here: allow functions in assert_part_value or... remove the validation. We probably should do the former first.

@yordis
Copy link
Member

yordis commented Oct 25, 2024

Are you able to pick this one up? Trying to focus in other parts right now

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

No branches or pull requests

3 participants