Make more max lengths constants and add additional MaxLengthExceeded checks (#50337)

* Add more MaxLengthExceeded checks

* remove some validations to reduce performance impact

* check length of generated entity ID

* dont check entity ID twice and use single context id length constant

* fix test

* add missing test
This commit is contained in:
Raman Gupta
2021-05-25 13:58:01 -04:00
committed by GitHub
parent abd6f739e8
commit 58e37435b3
5 changed files with 88 additions and 16 deletions

View File

@@ -26,9 +26,14 @@ ENTITY_MATCH_ALL: Final = "all"
# If no name is specified
DEVICE_DEFAULT_NAME: Final = "Unnamed Device"
# Max characters for an event_type (changing this requires a recorder
# database migration)
MAX_LENGTH_EVENT_TYPE: Final = 64
# Max characters for data stored in the recorder (changes to these limits would require
# a database migration)
MAX_LENGTH_EVENT_EVENT_TYPE: Final = 64
MAX_LENGTH_EVENT_ORIGIN: Final = 32
MAX_LENGTH_EVENT_CONTEXT_ID: Final = 36
MAX_LENGTH_STATE_DOMAIN: Final = 64
MAX_LENGTH_STATE_ENTITY_ID: Final = 255
MAX_LENGTH_STATE_STATE: Final = 255
# Sun events
SUN_EVENT_SUNSET: Final = "sunset"