Skip to content

Commit 7ed79b3

Browse files
Merge pull request #2125 from fetchai/fix/data_validation
fix validation of data pattern in config
2 parents 96cfc38 + b5ed517 commit 7ed79b3

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

aea/configurations/validation.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,10 @@ def check_excludes(path):
304304
# one of the values is env variable: skip data type check
305305
continue
306306

307-
if not issubclass(type(new_value), type(pattern_value)):
307+
if (
308+
not issubclass(type(new_value), type(pattern_value))
309+
and new_value is not None
310+
):
308311
errors.append(
309312
f"For attribute `{'.'.join(path)}` `{type(pattern_value).__name__}` data type is expected, but `{type(new_value).__name__}` was provided!"
310313
)

packages/fetchai/connections/p2p_libp2p/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ def __init__(self, **kwargs):
474474
else:
475475
raise ValueError(
476476
f"Couldn't find connection key for {str(ledger_id)} in connections keys. "
477-
"Please ensure agent private key is added"
477+
"Please ensure agent private key is added with `aea add-key`."
478478
)
479479

480480
uri = None

packages/fetchai/connections/p2p_libp2p/connection.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fingerprint:
1616
aea/pipe_unix.go: QmSzbAexrSUSA9ZE6VT6MmcWF5MhEcmceQjAbnfRoK7Ruv
1717
aea/pipe_windows.go: QmdYpfjgdgFbA6Pothg65NYM45ubfpZeKr8cVQoqbFzgUK
1818
check_dependencies.py: QmcZATMqEThMQBdsud1AwJEYtKq86VfPSXhnfdE7TSWcsc
19-
connection.py: QmRYfQW43udZixLWB1qgf5Xn3hE4M5Lt9kNVuszQwfrADB
19+
connection.py: QmadrZobnmUUT3yRc1NDQ7o3RAAxtsyMmsBbEXvmr7uH6s
2020
dht/dhtclient/dhtclient.go: QmaLy8KSMauF4rDY3NDCn9nBB2vA93dcq67T4SoVgyQ5Tt
2121
dht/dhtclient/dhtclient_test.go: QmS9SiLAojXYobqV9m5yeRpyPzt6JcSbQD78RNvSp6LPx6
2222
dht/dhtclient/options.go: QmaoJiavHescgx98inQjVUipPFRvcFFrodrScZ3fvrXJ4z

packages/hashes.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ fetchai/connections/http_server,QmWdLqcqD4zgdCRr3hYHDQ9ywkqkPigeBkK8jteaS9a5th
3434
fetchai/connections/ledger,QmTZaSmup7zcKwxr3k6yAT51zEKnmYowDhXpPVva7aC55i
3535
fetchai/connections/local,QmdbDffq5yzKhGdJpFdj5Bx4jepZYLoZNPRLEhucWtTNfB
3636
fetchai/connections/oef,Qmdz7XTS4pmaHLXhg3kfxCgDjayRJxL9ixxG9AfpxyPWyr
37-
fetchai/connections/p2p_libp2p,QmSnKzqAQrgPsEiJ99YbYjsMkpNvm5fBS53vpCc52iKZeQ
37+
fetchai/connections/p2p_libp2p,QmRhk1k9GhGknptkSRuaXMZMXsXBqqYN3HnDjFRjiXAUsZ
3838
fetchai/connections/p2p_libp2p_client,Qmdnz1kBA31EuUTxRSiLCWt7D6v8j7t4v2zQwaASLr91r8
3939
fetchai/connections/p2p_stub,Qma1A5oePh2K66QNHu7vfamAvBjMwKXgdgAdmu27YRZny8
4040
fetchai/connections/prometheus,Qmd4nVwPNGDVjsjL6EuS4xcnLCr3mRiQcFuW9snZ9qPrYs

tests/test_configurations/test_validation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,9 @@ def test_compare_data_pattern():
3232
== "For attribute `a` `str` data type is expected, but `int` was provided!"
3333
)
3434

35+
errors = validate_data_with_pattern({"a": None}, {"a": int})
36+
assert not errors
37+
3538
assert not validate_data_with_pattern(
3639
{"a": 12}, {"a": "${var}"}, skip_env_vars=True
3740
)

0 commit comments

Comments
 (0)