🐛 Skip group nodes when processing StyleDictionary tokens (#9025) (#9825)

StyleDictionary returns all nodes from the token tree, including
intermediate group nodes that have no corresponding origin token.
Previously process-sd-tokens tried to parse these as real tokens,
which produced garbage resolved values (e.g. {"$meta$": null, …})
and caused the entire token set validation to fail, blocking all
token creation and editing.

Skip sd-tokens whose origin lookup returns nil so that only actual
tokens are processed.

Signed-off-by: moorsecopers99 <patellscott18@gmail.com>
Signed-off-by: Andrés Moya <andres.moya@kaleidos.net>
Co-authored-by: moorsecopers99 <46223049+moorsecopers99@users.noreply.github.com>
This commit is contained in:
Andrés Moya 2026-05-22 12:46:09 +02:00 committed by GitHub
parent ee1b61914e
commit 3e733bb762
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -485,32 +485,36 @@
[sd-tokens get-origin-token]
(reduce
(fn [acc ^js sd-token]
(let [origin-token (get-origin-token sd-token)
value (.-value sd-token)
parsed-token-value (or
(parse-atomic-typography-value (:type origin-token) value)
(case (:type origin-token)
:typography (parse-composite-typography-value value)
:shadow (parse-sd-token-shadow-value value)
:color (parse-sd-token-color-value value)
:opacity (parse-sd-token-opacity-value value)
:stroke-width (parse-sd-token-stroke-width-value value)
:number (parse-sd-token-number-value value)
(parse-sd-token-general-value value)))
output-token (cond (:errors parsed-token-value)
(merge origin-token parsed-token-value)
(let [origin-token (get-origin-token sd-token)]
(if (nil? origin-token)
;; Skip group nodes that StyleDictionary returns alongside
;; actual tokens — they have no matching origin token.
acc
(let [value (.-value sd-token)
parsed-token-value (or
(parse-atomic-typography-value (:type origin-token) value)
(case (:type origin-token)
:typography (parse-composite-typography-value value)
:shadow (parse-sd-token-shadow-value value)
:color (parse-sd-token-color-value value)
:opacity (parse-sd-token-opacity-value value)
:stroke-width (parse-sd-token-stroke-width-value value)
:number (parse-sd-token-number-value value)
(parse-sd-token-general-value value)))
output-token (cond (:errors parsed-token-value)
(merge origin-token parsed-token-value)
(:warnings parsed-token-value)
(assoc origin-token
:resolved-value (:value parsed-token-value)
:warnings (:warnings parsed-token-value)
:unit (:unit parsed-token-value))
(:warnings parsed-token-value)
(assoc origin-token
:resolved-value (:value parsed-token-value)
:warnings (:warnings parsed-token-value)
:unit (:unit parsed-token-value))
:else
(assoc origin-token
:resolved-value (:value parsed-token-value)
:unit (:unit parsed-token-value)))]
(assoc acc (:name output-token) output-token)))
:else
(assoc origin-token
:resolved-value (:value parsed-token-value)
:unit (:unit parsed-token-value)))]
(assoc acc (:name output-token) output-token)))))
{} sd-tokens))
(defprotocol IStyleDictionary