Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

throw exception when key longer than 64 characters #28

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions gargoyle/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ def is_active(self, key, *instances, **kwargs):

>>> gargoyle.is_active('my_feature', request)
"""

# check for varchar(64)
if len(key) > 64:
raise ValueError('Gargoyle key can be max 64 chars, was: %s' % len(key))

default = kwargs.pop('default', False)

# Check all parents for a disabled state
Expand Down
5 changes: 5 additions & 0 deletions gargoyle/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ def is_active(gargoyle):
is_active_func = gargoyle.is_active

def wrapped(key, *args, **kwargs):

# check for varchar(64)
if len(key) > 64:
raise ValueError('Gargoyle key can be max 64 chars, was: %s' % len(key))

if key in self.keys:
return self.keys[key]
return is_active_func(key, *args, **kwargs)
Expand Down