brainlid

brainlid

OTP 26 was released and the Elixir 1.14.4 builds have been updated! Erlang OTP 26 changed how map keys are sorted, or not sorted actually. Check out this quick tip on how to customize IEx to always sort the map keys with your local development!

Showing Posts 1 to 7

christhekeele

christhekeele

This is great, and I love that you shared your personal ~/.iex.exs, definitely gives me some ideas!

I’ll add that I’m also a big fan of defaulting to always printing charlists as lists of numbers:

IEx.configure(
  inspect: [
    charlists: :as_lists
  ]
)

This prevents the common confusion of wondering why the list of integers you were operating on suddenly renders as text.

Hermanverschooten

Hermanverschooten

Great post, is there a way to do this for tests too?

Currently I am doing something like

if :erlang.system_info(:otp_release) >= '26' do
  ...
else
 ...
end

But that’s ugly.

jpcaruana

jpcaruana

Yes, good question.

I have unit tests failing on OPT 26 too. The failure is indirect, as I don’t do direct assertions on Map, but on json response.

Is there a way to deal with this, out of IEx.configure?

deepankar-j

deepankar-j

Did anyone find a solution for tests?

ColmB

ColmB

I think it depends on the issues exhibited by your tests. In terms of testing for error messages that are inspecting maps, note that the kernel inspect has the same sort_maps option as the IO.inspect. So you can do

Logger.error("Error: #{inspect(error, custom_options: [sort_maps: true])}")

However that is a bit of a PIA to do across the whole codebase. Does anyone know is it possible to set sort_maps as a default for inspect?

brainlid

brainlid OP

While this isn’t the answer you’re looking for, I find it’s best for tests to not count on the order of map. You can assert a match, for instance, where the fields in the map you care about for the test match the output.

These types of tests tend to hold up better as returned maps evolve with more data being added but aren’t relevant for the test. It avoids causing unrelated failures.

ColmB

ColmB

Yes we ended up at that conclusion ourselves. In the end there weren’t too many places where we had inspected a whole map into an error message. Currently fighting with Jason encoded AWS Publish data which again was tested against the whole expected message and which Jason is now randomly changing the order of. Nothing is ever simple!

— All posts loaded —

Where Next? Top

Trending in Blog Posts Top

bartblast
Hey folks, I just published a post about Hologram’s funding and where the project goes next - the short version: Curiosum as Main Spons...
New
pckrishnadas88
Hey everyone! :waving_hand: I’ve published Part 7 of the Building Distributed Systems in Elixir series, where we build core distributed ...
New
zorn
An educational side project in Elixir, Phoenix, and Tauri. I share what I learned while wiring Automerge into the BEAM, including how I s...
New
nathanl
Process labels are useful for visualization and debugging. Here’s why you should use them.
New
abreujp
New article: Elixir Project Structure — From mix new to a Growing Codebase I’ve published a new article in my Elixir learning series on d...
New
andreasronge
What happens if you design tools for LLMs instead of letting LLM use human tools ? Wrote a blog on why and what that enables. As I see ...
New
mudasobwa
Somewhere, right now, a senior engineer is on the verge of a nervous breakdown because his company will not let him switch from Claude to...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
mhanberg
Hi everyone! The first release candidate for the Expert language server project is now available! We’ve published a press release detai...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews