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

hex.pm publishing should not HTTP 500 on unexpected data in metadata.config #1250

Closed
inoas opened this issue May 1, 2024 · 2 comments
Closed

Comments

@inoas
Copy link

inoas commented May 1, 2024

mix hex.build
inspect contained metadata.config:

{<<"links">>,[]}.
{<<"name">>,<<"foobar">>}.
{<<"version">>,<<"0.0.1">>}.
{<<"description">>,<<"Testing · Middot · Character"/utf8>>}.
{<<"elixir">>,<<"~> 1.16">>}.
{<<"app">>,<<"foobar">>}.
{<<"licenses">>,[<<"MIT">>]}.
{<<"requirements">>,[]}.
{<<"files">>,
 [<<"lib">>,<<"lib/foobar.ex">>,<<".formatter.exs">>,<<"mix.exs">>,
  <<"README.md">>]}.
{<<"build_tools">>,[<<"mix">>]}.

versus
gleam export hex-tarball
inspect contained metadata.config

{<<"name">>, <<"foobar">>}.
{<<"app">>, <<"foobar">>}.
{<<"version">>, <<"0.0.1">>}.
{<<"description">>, <<"Testing · Middot · Character">>}.
{<<"licenses">>, [<<"Apache-2.0">>]}.
{<<"build_tools">>, [<<"gleam">>]}.
{<<"links">>, [
]}.
{<<"requirements">>, [
  {<<"gleam_stdlib">>, [
    {<<"app">>, <<"gleam_stdlib">>},
    {<<"optional">>, false},
    {<<"requirement">>, <<">= 0.34.0 and < 2.0.0">>}
  ]}
]}.
{<<"files">>, [
  <<"README.md">>,
  <<"gleam.toml">>,
  <<"src/foobar.app.src">>,
  <<"src/foobar.erl">>,
  <<"src/foobar.gleam">>
]}.

When publishing these tarballs via API to hex.pm it would return an HTTP 500 error.

... /utf8 was missing from the description value, but that should result in an HTTP 400 error instead of an HTTP 500, right?

@ericmj
Copy link
Member

ericmj commented May 6, 2024

Unfortunately Ecto does not validate UTF8 for strings, in addition Postgresql does not allow null <<0>> bytes even though it's valid UTF8. Maybe we can do a custom Ecto type everywhere we use :string today that adds the validation, but ideally Ecto would do this out of the box. I will bring it up with the Ecto team.

@ericmj
Copy link
Member

ericmj commented May 17, 2024

Implemented in phoenixframework/phoenix_ecto#175.

@ericmj ericmj closed this as completed in 0ffc66f May 17, 2024
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

2 participants