figma-plugin icon indicating copy to clipboard operation
figma-plugin copied to clipboard

Plugin Crash on Missing Variable During Style Import

Open six7 opened this issue 9 months ago • 0 comments

Bug: Plugin Crashes During Style Import Due to Missing Variables

When attempting to import styles in version 2.5.1 of the plugin, the process crashes if certain referenced variables do not exist.

Steps to Reproduce:

  1. Attempt to import styles from the provided Figma file link.
  2. Ensure that the styles reference variables that may not exist in the file.

Expected Behavior: The plugin should successfully import the styles, disregarding any missing variables without crashing the entire process.

Actual Behavior: The import process crashes when it encounters a missing variable, for example, font-size/54, which causes the plugin to break.

Suggested Fix: Implement a try/catch mechanism during the reference lookup; if a variable is not found, the plugin should use the raw value from the style instead of terminating the process.

Slack thread: https://hyma-team.slack.com/archives/C04V8U8UH0F/p1747199683619199?thread_ts=1747199683.619199&cid=C04V8U8UH0F

Attachments

📷 Image attachment: CleanShot 2025-05-14 at [email protected] (PNG, 160 KB)

📷 Image attachment: Screenshot 2025-05-16 at 7.53.05 PM.png (PNG, 1240 KB)

Show all messages marco.krenn wrote: @akshay i just tried importing styles with 2.5.1 and the plugin crashed with

akshay wrote: @marco.krenn if its a test file or a duplicate one if its production, can I have access to those, because I am being able to import styles, maybe there is a specific type crashing it

six.jan wrote: same, able to import color,text,shadow

akshay wrote: yeah

marco.krenn wrote: trying to export the file it's in another org so need to bring it to us

marco.krenn wrote: @akshay @six.jan this is the file https://www.figma.com/design/zMeQRBqw5YppHPrLdaVnRc/Foundation---Token-Studio--Copy----Partial-file-saved-15-05-2025?node-id=12-2&p=f&t=bV0aftZsYAqDNkr0-0|https://www.figma.com/design/zMeQRBqw5YppHPrLdaVnRc/Foundation---Token-Studio--Copy[…]al-file-saved-15-05-2025?node-id=12-2&p=f&t=bV0aftZsYAqDNkr0-0

marco.krenn wrote: @akshay did you have some time to look into the import on that file?

akshay wrote: yes, just checked, there is no issue with the styles

akshay wrote: there is some issue with the variables which is hijacking the import process

akshay wrote: for example this variable referenced in the style font size is font-size/54 which does not exist in the file

marco.krenn wrote: oh, but this should not break the plugin when we only import the style, but i guess it tries to make a lookup

akshay wrote: yes you are right it should not be breaking the entire process

six.jan wrote: oh got it, so the issue is that a single variable currently - if it does not exist - causes the whole thing to break? agree, we should be more resilient and try/catch the reference lookup, if no variable is found, just use the raw value (which AFAIK should be on the style still?)

six.jan wrote: @issue_assistant create issue in tokens-studio/figma-plugin

Update (2025-05-16T17:03:36.443Z)

  • Actual Behavior Update: The import process crashes when it encounters a missing variable, such as font-size/54, which does not exist in the file. It has been confirmed that the plugin attempts to make a lookup for the variable, which leads to the crash.
  • Suggested Improvement: It has been agreed that the plugin should implement a try/catch mechanism during the reference lookup. If a variable is not found, the plugin should use the raw value from the style instead of terminating the process.
  • New Suggestion: If there is an issue with the linked variable, the plugin should ideally create a new token and link it to the token created from the style.

Attachments

📷 Image attachment: CleanShot 2025-05-14 at [email protected] (PNG, 160 KB)

📷 Image attachment: Screenshot 2025-05-16 at 7.53.05 PM.png (PNG, 1240 KB)

six7 avatar May 16 '25 16:05 six7