diff --git a/bin/weewx/tags.py b/bin/weewx/tags.py
index cdc8385a..57812196 100644
--- a/bin/weewx/tags.py
+++ b/bin/weewx/tags.py
@@ -482,7 +482,12 @@ class AggTypeBinder(object):
def _do_query(self):
"""Run a query against the databases, using the given aggregation type."""
- db_manager = self.db_lookup(self.data_binding)
+ try:
+ # Get the appropriate database manager
+ db_manager = self.db_lookup(self.data_binding)
+ except weewx.UnknownBinding:
+ # Don't recognize the binding.
+ raise AttributeError(self.data_binding)
try:
# If we cannot perform the aggregation, we will get an UnknownType or
# UnknownAggregation error. Be prepared to catch it.
diff --git a/bin/weewx/tests/expected/StandardTest/index.html b/bin/weewx/tests/expected/StandardTest/index.html
index ccf9d446..8b791ee5 100644
--- a/bin/weewx/tests/expected/StandardTest/index.html
+++ b/bin/weewx/tests/expected/StandardTest/index.html
@@ -506,6 +506,10 @@
Max Temperature in alt_binding |
25.1°F |
+
+ | Max Temperature with bogus binding |
+ $day($data_binding='foo_binding').outTemp.max |
+
| Min temp with explicit conversion to Celsius |
3.8°C |
diff --git a/bin/weewx/tests/expected/StandardTest/metric/index.html b/bin/weewx/tests/expected/StandardTest/metric/index.html
index 53ddee96..6677e496 100644
--- a/bin/weewx/tests/expected/StandardTest/metric/index.html
+++ b/bin/weewx/tests/expected/StandardTest/metric/index.html
@@ -506,6 +506,10 @@
Max Temperature in alt_binding |
-3.9°C |
+
+ | Max Temperature with bogus binding |
+ $day($data_binding='foo_binding').outTemp.max |
+
| Min temp with explicit conversion to Celsius |
3.8°C |
diff --git a/bin/weewx/tests/test_skins/StandardTest/index.html.tmpl b/bin/weewx/tests/test_skins/StandardTest/index.html.tmpl
index ea01caf3..8309bc11 100644
--- a/bin/weewx/tests/test_skins/StandardTest/index.html.tmpl
+++ b/bin/weewx/tests/test_skins/StandardTest/index.html.tmpl
@@ -506,6 +506,10 @@ FALSE#slurp
Max Temperature in alt_binding |
$day($data_binding='alt_binding').outTemp.max |
+
+ | Max Temperature with bogus binding |
+ $day($data_binding='foo_binding').outTemp.max |
+
| Min temp with explicit conversion to Celsius |
$day.outTemp.min.degree_C |
diff --git a/docs/changes.md b/docs/changes.md
index c2af064c..94ceba05 100644
--- a/docs/changes.md
+++ b/docs/changes.md
@@ -49,6 +49,9 @@ user jocelynj! PR #842.
Fix problem that prevented wee_device --set-retransmit from working on
Vantage stations.
+Using a bad data binding with an aggregation tag no longer results in an
+exception. Instead, it shows the tag in the results. Related to PR #817.
+
### 4.10.1 01/30/2023