fix(yes-core): honour prefix for array values in HashUtils.deep_flatten_hash#31
Merged
Merged
Conversation
…en_hash
The `String|Symbol, Array` branch keyed array values by their bare name
(`key.to_s`), ignoring the `prefix` that scalar and nested-hash keys honour.
Callers passing a prefix therefore got a mix of namespaced and un-namespaced
keys (e.g. `deep_flatten_hash({ tags: [...] }, 'span')` produced `"tags"`
instead of `"span.tags"`). Apply the prefix consistently. Callers passing no
prefix are unaffected. Adds spec coverage for deep_flatten_hash and deep_dup.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Yes::Core::Utils::HashUtils.deep_flatten_hashapplied theprefixto scalar and nested-hash keys, but not to array-valued keys — theString|Symbol, Arraybranch keyed them by the barekey.to_s:So a caller passing a prefix got a mix of namespaced and un-namespaced keys, e.g.:
Why
Discovered while adding
webhook.*OpenTelemetry span attributes inapplication_management_system, where the un-prefixed array keys (assignees,documents) escaped thewebhook.namespace and had to be re-namespaced with atransform_keysworkaround. This makes the helper consistent so that workaround can be dropped once released.Safety
Callers that pass no prefix are unaffected — with
prefix = nilboth branches producekey.to_s(every existing caller in the codebase calls it without a prefix).Tests
Adds
deep_flatten_hashcoverage (flat, nested, prefixed scalar/hash, prefixed array regression, no-prefix array) and adeep_duptest. CHANGELOG entry under Unreleased.🤖 Generated with Claude Code