Skip to content

Conversation

@san650
Copy link
Contributor

@san650 san650 commented Oct 24, 2025

As part of fixing hexpm/hex#1092 we need to parse nested maps from the metadata.config file so these can be saved in the Package schema.

Related PR hexpm/hex#1096

If we don't, when trying to send nested maps as part of the Package's extra field in the mix.exs file it will raise this error in hexpm/hexpm API:

  1) test POST /api/packages/:name/releases create release and new package as user (HexpmWeb.API.ReleaseControllerTest)
     test/hexpm_web/controllers/api/release_controller_test.exs:30
     ** (Protocol.UndefinedError) protocol Jason.Encoder not implemented for type Tuple, Jason.Encoder protocol must always be explicitly implemented. This protocol is implemented for the following type(s): Any, Atom, BitString, Date, DateTime, Decimal, Ecto.Association.NotLoaded, Ecto.Schema.Metadata, Float, Hexpm.Accounts.RecoveryCode, Integer, Jason.Fragment, Jason.OrderedObject, List, Map, NaiveDateTime, Time, Version

     Got value:

         {"bar", [{"a", "b"}]}

     stacktrace:
       (jason 1.4.4) lib/jason.ex:213: Jason.encode_to_iodata!/2
       (postgrex 0.19.3) lib/postgrex/type_module.ex:1084: Postgrex.DefaultTypes.encode_params/3
       (postgrex 0.19.3) lib/postgrex/query.ex:75: DBConnection.Query.Postgrex.Query.encode/3
       (db_connection 2.7.0) lib/db_connection.ex:1449: DBConnection.encode/5
       (db_connection 2.7.0) lib/db_connection.ex:1549: DBConnection.run_prepare_execute/5
       (db_connection 2.7.0) lib/db_connection.ex:772: DBConnection.parsed_prepare_execute/5
       (db_connection 2.7.0) lib/db_connection.ex:764: DBConnection.prepare_execute/4
       (postgrex 0.19.3) lib/postgrex.ex:306: Postgrex.query/4
       (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1150: Ecto.Adapters.SQL.struct/10
       (ecto 3.12.5) lib/ecto/repo/schema.ex:837: Ecto.Repo.Schema.apply/4
       (ecto 3.12.5) lib/ecto/repo/schema.ex:416: anonymous fn/15 in Ecto.Repo.Schema.do_insert/4
       (ecto 3.12.5) lib/ecto/multi.ex:897: Ecto.Multi.apply_operation/5
       (elixir 1.18.4) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3
       (ecto 3.12.5) lib/ecto/multi.ex:870: anonymous fn/5 in Ecto.Multi.apply_operations/5
       (ecto_sql 3.12.1) lib/ecto/adapters/sql.ex:1400: anonymous fn/3 in Ecto.Adapters.SQL.checkout_or_transaction/4
       (db_connection 2.7.0) lib/db_connection.ex:1756: DBConnection.run_transaction/4
       (ecto 3.12.5) lib/ecto/repo/transaction.ex:18: Ecto.Repo.Transaction.transaction/4
       (hexpm 0.0.1) lib/hexpm/repository/releases.ex:51: Hexpm.Repository.Releases.publish/8
       (hexpm 0.0.1) lib/hexpm_web/controllers/api/release_controller.ex:143: HexpmWeb.API.ReleaseController.handle_tarball/5
       (hexpm 0.0.1) lib/hexpm_web/controllers/api/release_controller.ex:1: HexpmWeb.API.ReleaseController.action/2

@ericmj ericmj merged commit 76454e5 into hexpm:main Oct 25, 2025
6 checks passed
@ericmj
Copy link
Member

ericmj commented Oct 25, 2025

Thank you! 💜

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.

2 participants