fix(actions): strip r# from raw-ident fluent arg keys (FJ-40) #50

Merged
nrupard merged 1 commit from fix/ftl-raw-ident-arg-FJ-40 into main 2026-06-08 19:48:23 +02:00
Member

Summary

fj actions dispatch <name> <ref> -I k=v panicked while formatting its own success message even though the dispatch API call succeeded (Resolver error: Unknown variable: $ref followed by a failed to format localized text panic).

Root cause

The ftl_arg! macro set each Fluent argument key with stringify!($var_name). For the raw identifier r#ref (used because ref is a Rust keyword), stringify!(r#ref) yields "r#ref", so the argument was stored under r#ref while msg-actions-dispatch-success looks up the bare $ref. The variable stayed unbound, Fluent raised a resolver error, and ftl_println! panicked.

Fix

Added a fluent_key helper that strips a leading r# from the stringified identifier and routed both ftl_arg! arms through it. This is the general fix: any current or future raw-ident argument now binds to the bare Fluent variable the template references, not just $ref.

Tests

  • raw_ident_arg_binds_bare_fluent_variable: formats the real msg-actions-dispatch-success via ftl_try_format! (which returns None on any resolver error) and asserts the ref and name interpolate.
  • fluent_key_strips_raw_ident_prefix: direct unit test of the helper.

cargo fmt --check, cargo clippy --all-targets -- -D warnings, and the full cargo test suite pass in the rust-builder-glibc image. The --json output path is untouched.

Closes FJ-40.

## Summary `fj actions dispatch <name> <ref> -I k=v` panicked while formatting its own success message even though the dispatch API call succeeded (`Resolver error: Unknown variable: $ref` followed by a `failed to format localized text` panic). ## Root cause The `ftl_arg!` macro set each Fluent argument key with `stringify!($var_name)`. For the raw identifier `r#ref` (used because `ref` is a Rust keyword), `stringify!(r#ref)` yields `"r#ref"`, so the argument was stored under `r#ref` while `msg-actions-dispatch-success` looks up the bare `$ref`. The variable stayed unbound, Fluent raised a resolver error, and `ftl_println!` panicked. ## Fix Added a `fluent_key` helper that strips a leading `r#` from the stringified identifier and routed both `ftl_arg!` arms through it. This is the general fix: any current or future raw-ident argument now binds to the bare Fluent variable the template references, not just `$ref`. ## Tests - `raw_ident_arg_binds_bare_fluent_variable`: formats the real `msg-actions-dispatch-success` via `ftl_try_format!` (which returns `None` on any resolver error) and asserts the ref and name interpolate. - `fluent_key_strips_raw_ident_prefix`: direct unit test of the helper. `cargo fmt --check`, `cargo clippy --all-targets -- -D warnings`, and the full `cargo test` suite pass in the rust-builder-glibc image. The `--json` output path is untouched. Closes FJ-40.
fix(actions): strip r# from raw-ident fluent arg keys
All checks were successful
Check / fmt + clippy + build + tests (pull_request) Successful in 38s
Create release / Create release from merged PR (pull_request) Has been skipped
dd21202d4e
The `ftl_arg!` macro keyed each Fluent argument with `stringify!($var_name)`. For a raw identifier such as `r#ref`, `stringify!` yields `"r#ref"`, so the argument was stored under `r#ref` while templates reference the bare `$ref`. Fluent then reported `Unknown variable: $ref` and `ftl_println!` panicked, so `fj actions dispatch <name> <ref> -I k=v` aborted while formatting its own success line even though the dispatch API call had succeeded.

Add a `fluent_key` helper that strips a leading `r#` from the stringified identifier and route both `ftl_arg!` arms through it, so any raw-ident argument binds to the variable the template actually looks up. Regression tests format the real `msg-actions-dispatch-success` message via `ftl_try_format!` and assert the ref interpolates with no resolver error, plus a direct unit test of `fluent_key`.

#FJ-40

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
nrupard deleted branch fix/ftl-raw-ident-arg-FJ-40 2026-06-08 19:48:23 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pandoras-box/forgejo-cli!50
No description provided.