aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--examples/simple/custom_option.py2
-rw-r--r--mitmproxy/optmanager.py2
-rw-r--r--test/mitmproxy/test_optmanager.py3
3 files changed, 6 insertions, 1 deletions
diff --git a/examples/simple/custom_option.py b/examples/simple/custom_option.py
index e9c34850..a8b4e778 100644
--- a/examples/simple/custom_option.py
+++ b/examples/simple/custom_option.py
@@ -3,7 +3,7 @@ from mitmproxy import ctx
def start(options):
ctx.log.info("Registering option 'custom'")
- options.add_option("custom", str, "default", "A custom option")
+ options.add_option("custom", bool, False, "A custom option")
def configure(options, updated):
diff --git a/mitmproxy/optmanager.py b/mitmproxy/optmanager.py
index a72a4355..fc540b74 100644
--- a/mitmproxy/optmanager.py
+++ b/mitmproxy/optmanager.py
@@ -338,6 +338,8 @@ class OptManager:
optname, optval = parts[0], None
else:
optname, optval = parts[0], parts[1]
+ if optname not in self._options:
+ raise exceptions.OptionsError("No such option %s" % optname)
o = self._options[optname]
if o.typespec in (str, typing.Optional[str]):
diff --git a/test/mitmproxy/test_optmanager.py b/test/mitmproxy/test_optmanager.py
index 6e275802..8ca35984 100644
--- a/test/mitmproxy/test_optmanager.py
+++ b/test/mitmproxy/test_optmanager.py
@@ -346,3 +346,6 @@ def test_set():
assert opts.seqstr == ["foo", "bar"]
opts.set("seqstr")
assert opts.seqstr == []
+
+ with pytest.raises(exceptions.OptionsError):
+ opts.set("nonexistent=wobble")