Skip to content

fix: Semver traits crash on Elixir 1.12 and 1.13 - #81

Merged
khvn26 merged 4 commits into
mainfrom
fix/elixir-1.12-version-to-string
Nov 23, 2026
Merged

khvn26 merged 4 commits into
mainfrom
fix/elixir-1.12-version-to-string

Conversation

@khvn26

@khvn26 khvn26 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Version.to_string/1 was added in Elixir 1.14, but the package declares elixir: "~> 1.12". On 1.12 and 1.13, three code paths raise UndefinedFunctionError when they meet a semver trait value:

  • Flagsmith.Engine.Evaluator.to_str/1, during local evaluation
  • Flagsmith.Engine.Mappers.map_trait_value/1
  • JSON encoding of Flagsmith.Schemas.Traits.Trait.Value

%Version{} implements String.Chars on every supported Elixir, so this uses to_string/1 instead. The output is the same.

Nothing in CI tests the minimum version, which is how this and the ** operator from #79 got through (that one also stopped 2.6.0 and 2.7.0 from publishing to Hex). To close that gap, the build job now runs on a matrix:

Entry Runner Compile (--warnings-as-errors) Tests Format and dialyzer
.tool-versions (Elixir 1.15.2, OTP 26) ubuntu-latest ✅ ✅ ✅
Elixir 1.12, OTP 24 (the minimum, and what the Hex publish uses) ubuntu-24.04, the newest runner with OTP 24 builds ✅ ✅ —

Format and dialyzer only run on .tool-versions, since their output differs between versions. Each entry has its own cache keys.

To make that pass:

  • Logger.warn/1 is deprecated from Elixir 1.15 and breaks --warnings-as-errors, so it's replaced with Logger.warning/2, which has existed since 1.11.
  • Two fixes to make the tests work on 1.12:
    • ExUnit.CaptureLog.with_log/1 (1.13+) is replaced with capture_log/2.
    • assert_request compares JSON request bodies as decoded data, not raw strings, because key order differs between OTP versions.
    • Also replaced a deprecated level: :warn with :warning.

Verified locally in containers for both entries:

  • mix compile --warnings-as-errors passes.
  • mix test passes, 433 tests and 0 failures.
  • On 1.15.2, mix format --check-formatted and mix dialyzer pass.

Before the fix, the 1.12 entry fails, both at compile time (Version.to_string/1 is undefined or private) and in tests (UndefinedFunctionError).

@khvn26
khvn26 requested a review from a team as a code owner November 23, 2026 16:26
@khvn26
khvn26 requested review from emyller and removed request for a team November 23, 2026 16:26
cubic-dev-ai[bot]
cubic-dev-ai Bot previously approved these changes Nov 23, 2026

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

No issues found across 4 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Replaces the Elixir 1.14-only Version.to_string/1 with the universally available to_string/1 in three semver trait paths and adds a CI job compiling on Elixir 1.12 with warnings-as-errors. The fix is small, behavior-preserving, and directly addresses the declared minimum-version crash.

Turn on auto-fix | Re-trigger cubic

@codspeed

codspeed Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 12 untouched benchmarks


Comparing fix/elixir-1.12-version-to-string (3f28f73) with main (58d015b)

Open in CodSpeed

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

0 issues found across 7 files (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Auto-approved: Replaces Version.to_string/1 with to_string/1 in semver trait paths and adds CI coverage on Elixir 1.12, plus Logger.warn swaps. The fix is small, behavior-preserving, and covers the declared minimum-version crash.

Turn on auto-fix | Re-trigger cubic

@khvn26
khvn26 merged commit e1890e8 into main Nov 23, 2026
7 checks passed
@khvn26
khvn26 deleted the fix/elixir-1.12-version-to-string branch November 23, 2026 16:49
khvn26 pushed a commit that referenced this pull request Nov 23, 2026
🤖 I have created a release *beep* *boop*
---


##
[2.7.2](v2.7.1...v2.7.2)
(2026-11-23)


### Bug Fixes

* Semver traits crash on Elixir 1.12 and 1.13
([#81](#81))
([e1890e8](e1890e8))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).
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.

1 participant