Case-sensitive tokens

Created on 17 April 2025, 26 days ago

Problem/Motivation

We have a case where we're fetching some data from an external API using the HTTP Client Manager module. The external API returns a JSON object with some arbitrary properties.

Some of these JSON properties begin with capitalized letters. For now, such properties cannot be accessed with token syntax, mainly because of the following part within TokenDecoratorTrait:

protected function normalizeKey(string $key): string {
    $key = mb_strtolower(trim($key));
    //...
}

As the key is enforced to have lowercase characters. I think we did this because we wanted to ensure consistency with Drupal's token syntax which appears to always be lowercased.

Now the question arises how we may be able to access the properties with some capitalized letters.

Steps to reproduce

Proposed resolution

In the particular case of HTTP client manager, we read out from the temporary storage in order to get the received data. The action of that module puts it into the storage as array. So when reading from the storage and put it as token in ECA, then ECA automatically converts the array into a DataTransferObject.

Currently see two options:

  1. Based on description above, we could extend the DataTransferObject to lookup property keys with a case-insensitive comparison method.
  2. Remove mb_strtolower from the normalizeKey method mentioned above.

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Code

Created by

🇩🇪Germany mxh Offenburg

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @mxh
  • 🇩🇪Germany mxh Offenburg
  • 🇩🇪Germany jurgenhaas Gottmadingen

    That's an interesting one. I wonder if the token API has any documentation about the keys being lowercase, of if we just assumed that would be what's happening? Wasn't able to find any such documentation, and assume that we've been too cautious here. Mixed case token keys should be perfectly OK. So, I tend to lean towards option 2, combined with a warning in the release notes that this may break existing models.

Production build 0.71.5 2024