Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No type checking in store config values #521

Open
mStirner opened this issue Dec 29, 2024 · 1 comment
Open

No type checking in store config values #521

mStirner opened this issue Dec 29, 2024 · 1 comment
Labels
bug Something that should not be like that close Discuss to be closed or closed soon component:store

Comments

@mStirner
Copy link
Member

grafik
There is no error/type checking for store config values.

When type=number, you can set a string as value.

@mStirner mStirner added bug Something that should not be like that component:store labels Dec 29, 2024
@mStirner mStirner added the close Discuss to be closed or closed soon label Jan 15, 2025
@mStirner
Copy link
Member Author

mStirner commented Jan 15, 2025

Not reproducable on dev system.
Type checking is implemented :

if (typeof (value) !== obj.type && value !== null) {
// throw error or just set false?
throw new TypeError(`value is not type of ${obj.type}, its: ${typeof value}`);
//return false;
}

And joi throws also validation error:

[Error [ValidationError]: "config[0].value" must be a boolean] {
  _original: {
    _id: '66e567f84469378713d4ad22',
    name: 'Phoscon Gateway (Phoscon Gateway)',
    labels: [
      'device=66e567f84469378713d4ad1f',
      'zigbee=true',
      'phoscon=true'
    ],
    config: [ [Object] ],
    timestamps: { created: 1726310392663, updated: 1736950106970 },
    description: null,
    uuid: 'a28d5569-e94c-4713-b2d4-acbd46b914eb'
  },
  details: [
    {
      message: '"config[0].value" must be a boolean',
      path: [Array],
      type: 'boolean.base',
      context: [Object]
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something that should not be like that close Discuss to be closed or closed soon component:store
Projects
None yet
Development

No branches or pull requests

1 participant