Skip to content

chore: upgrade Elixir to v1.20, erlang to v29 - #795

Open
rwaskiewicz wants to merge 4 commits into
mainfrom
rw/elixir-1.20
Open

chore: upgrade Elixir to v1.20, erlang to v29#795
rwaskiewicz wants to merge 4 commits into
mainfrom
rw/elixir-1.20

Conversation

@rwaskiewicz

Copy link
Copy Markdown
Contributor

Asana task: Update Screenplay to Elixir 1.20 / OTP 29

Description

Update elixir from 1.17.3-otp-27 to 1.20.2-otp-29. Update erlang from 27.3.4 to 29.0.2.

Version 0.18 of faker is incompatible with elixir 1.20, which necessitated an upgrade.

Update Logger configuration & install logger_backends, which is where the pre-existing logging backend system has moved to.

Elixir's built-in JSON module that was added in v1.18 replaces most usages of Jason in the codebase. Jason has been left as a dependency for screens configuration saving (used for emergency takeover setting) - JSON does not support a pretty-printing, which is relied on to save a well-formed configuration file. :json.format was considered, but does not transform nil to null, which Jason.encode!() does. Given that we are looking to move this configuration to Postgres, keep Jason for the time being, until the migration is complete and we may revisit.

Reorder lists in tests whose ordering has changed as a result of changes in erlang.

Elixir v1.20 was able to detect unused require Logger statements, which are removed.

Add a Phoenix code reloading listener to suppress warnings that were printed to STDOUT after the upgrade when running the dev server.

  • For features with a design/UX component, deployed branch to dev-green and let product know it's ready for review.

Update elixir from 1.17.3-otp-27 to 1.20.2-otp-29. Update erlang from
27.3.4 to 29.0.2.

Version 0.18 of `faker` is incompatible with elixir 1.20, which
necessitated an upgrade.

Update Logger configuration & install `logger_backends`, which is where
the pre-existing logging backend system has moved to.

Elixir's built-in `JSON` module that was added in v1.18 replaces most
usages of `Jason` in the codebase. `Jason` has been left as a
dependency for screens configuration saving (used for emergency
takeover setting) - `JSON` does not support a pretty-printing, which is
relied on to save a well-formed configuration file. `:json.format` was
considered, but does not transform `nil` to `null`, which
`Jason.encode!()` does. Given that we are looking to move this
configuration to Postgres, keep `Jason` for the time being, until the
migration is complete and we may revisit.

Reorder lists in tests whose ordering has changed as a result of
changes in erlang.

Elixir v1.20 was able to detect unused `require Logger` statements,
which are removed.

Add a Phoenix code reloading listener to suppress warnings that were
printed to STDOUT after the upgrade when running the dev server.
@moduledoc false

@spec upload_takeover_image(String.t(), binary(), String.t()) :: :ok
def upload_takeover_image(_alert_id, _image_data, _image_type), do: :ok

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

When running mix test with the original version of this function, we get the following:

warning: the following clause cannot match because the previous clauses already matched all possible values:

         error ->

     it attempts to match on the result of:

         Screenplay.EmergencyTakeoverTool.Images.TestFetch.upload_takeover_image(
           alert_id,
           image_binary,
           image_type
         )

     which has the already matched type:

         dynamic(:ok)

     where "error" was given the type:

         # type: dynamic(:ok)
         # from: lib/screenplay_web/controllers/emergency_takeover_tool/alert_controller.ex:199:17
         error

     type warning found at:
     │
 199 │                 error -> {:halt, error}
     │                       ~
     │
     └─ lib/screenplay_web/controllers/emergency_takeover_tool/alert_controller.ex:199:23: ScreenplayWeb.EmergencyTakeoverTool.AlertController.upload_takeover_images/2

Is there a better way to appease the type system here?

@digitalcora digitalcora Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking of this almost as a warning that the calling code is untestable, because the :error branch can never be reached when calling the test version of the function, which always returns :ok. A possible solution would be to make the function return :error when a specific sentinel value is supplied as one of the arguments. (That alone would probably resolve the compiler error without actually forcing us to add test coverage of the branch, but that would be a logical next step.)

@rwaskiewicz
rwaskiewicz marked this pull request as ready for review August 7, 2026 15:16
@rwaskiewicz
rwaskiewicz requested a review from a team as a code owner August 7, 2026 15:16
Comment thread config/config.exs Outdated

# Configures Elixir's Logger
config :logger, :console,
config :logger, :default_handler,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Curious about the change from console to default_handler/default_formatter here — this wasn't something I encountered when I upgraded RTS. The actual items being configured (at least the format strings) seem like they'd only be relevant to the console logger. And what is the difference between :default_handler, format: "..." and :default_formatter, format: "..."?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

And what is the difference between :default_handler, format: "..." and :default_formatter, format: "..."?

That's a goof on my part - this should have been default_formatter on this line. That part I've fixed in 5ae5bdb

Curious about the change from console to default_handler/default_formatter here — this wasn't something I encountered when I upgraded RTS. The actual items being configured (at least the format strings) seem like they'd only be relevant to the console logger.

I need to do a little more digging, but my understanding/theory ATM is that we are relying on console/STDOUT for getting things into Splunk. I'm not 100% sure where that log sink is configured (that I need to look at). I'm going to partially confirm that in 5ae5bdb - the current version that's deployed is missing the metadata fields in it (presumably bc I put used the wrong key here). I'll deploy that momentarily, and see if that adds them back.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since we're sending STDOUT to Splunk, this is why we have this configuration still. I think b/w this thread and this one the original question is answered, but LMK if that's not the case

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think my question stands, but to rephrase: Why is any change needed here at all? Why doesn't :console still work?

@moduledoc false

@spec upload_takeover_image(String.t(), binary(), String.t()) :: :ok
def upload_takeover_image(_alert_id, _image_data, _image_type), do: :ok

@digitalcora digitalcora Aug 7, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I'm thinking of this almost as a warning that the calling code is untestable, because the :error branch can never be reached when calling the test version of the function, which always returns :ok. A possible solution would be to make the function return :error when a specific sentinel value is supplied as one of the arguments. (That alone would probably resolve the compiler error without actually forcing us to add test coverage of the branch, but that would be a logical next step.)

Comment thread lib/screenplay/application.ex
@rwaskiewicz
rwaskiewicz requested a review from digitalcora August 7, 2026 18:01
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