Skip to content

(runtime-core): Runtime error when mistakenly converting symbols to a string during props validation #8487

@mattersj

Description

@mattersj

Vue version

3.3.4

Link to minimal reproduction

https://play.vuejs.org/#eNqFjsEKgzAQRH9lyaUWiqFXiULxBwSvuViNNWCSJVkLRfz3Rm2hhUJvO7uzb2ZmF8T0PimWMRFar5EgKJqwkFYbdJ6gdAah987AIeWrWO0HaaVtnQ3R/jBXN0IO9TYkR2kF31EREgUpg2NDKioAMZyLqvHKkuBx3FZbQkYqUC7ZjpMMeDwK/vHMTuwd/6Ntp3ptVeUdhmSGFZZBTV7bGyz/K5WDHrtXo+/Q5QneXWVa

Steps to reproduce

Steps to reproduce the bug from scratch (repro already has this covered):

  1. Pass a symbol as a prop value to a component that expects another type.
  2. Observe a runtime error since symbols can't be converted to string or number.

What is expected?

A classic warning about type mismatch, e.g. Invalid prop: type check failed for prop "propName". Expected String, got Symbol

What is actually happening?

A runtime error because getInvalidTypeMessage function is trying to convert the symbol to a string/number.

System Info

System:
    OS: macOS 12.4
    CPU: (10) arm64 Apple M1 Pro
    Memory: 92.69 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
    npm: 8.19.2 - ~/.nvm/versions/node/v18.12.1/bin/npm
  Browsers:
    Chrome: 114.0.5735.90
    Firefox: 112.0.2
    Safari: 15.5
  npmPackages:
    vue: ^3.3.4 => 3.3.4

Any additional comments?

The fix could be pretty straightforward: check if we have a symbol in styleValue function and do not convert a value to anything else since it won't be useful anyway.

I'm going to submit a PR that fixes this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔨 p3-minor-bugPriority 3: this fixes a bug, but is an edge case that only affects very specific usage.has PRA pull request has already been submitted to solve the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions