Skip to content

Commit

Permalink
Merge pull request #2125 from fetchai/fix/data_validation
Browse files Browse the repository at this point in the history
fix validation of data pattern in config
  • Loading branch information
DavidMinarsch authored Jan 6, 2021
2 parents 96cfc38 + b5ed517 commit 7ed79b3
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion aea/configurations/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ def check_excludes(path):
# one of the values is env variable: skip data type check
continue

if not issubclass(type(new_value), type(pattern_value)):
if (
not issubclass(type(new_value), type(pattern_value))
and new_value is not None
):
errors.append(
f"For attribute `{'.'.join(path)}` `{type(pattern_value).__name__}` data type is expected, but `{type(new_value).__name__}` was provided!"
)
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/connections/p2p_libp2p/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ def __init__(self, **kwargs):
else:
raise ValueError(
f"Couldn't find connection key for {str(ledger_id)} in connections keys. "
"Please ensure agent private key is added"
"Please ensure agent private key is added with `aea add-key`."
)

uri = None
Expand Down
2 changes: 1 addition & 1 deletion packages/fetchai/connections/p2p_libp2p/connection.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fingerprint:
aea/pipe_unix.go: QmSzbAexrSUSA9ZE6VT6MmcWF5MhEcmceQjAbnfRoK7Ruv
aea/pipe_windows.go: QmdYpfjgdgFbA6Pothg65NYM45ubfpZeKr8cVQoqbFzgUK
check_dependencies.py: QmcZATMqEThMQBdsud1AwJEYtKq86VfPSXhnfdE7TSWcsc
connection.py: QmRYfQW43udZixLWB1qgf5Xn3hE4M5Lt9kNVuszQwfrADB
connection.py: QmadrZobnmUUT3yRc1NDQ7o3RAAxtsyMmsBbEXvmr7uH6s
dht/dhtclient/dhtclient.go: QmaLy8KSMauF4rDY3NDCn9nBB2vA93dcq67T4SoVgyQ5Tt
dht/dhtclient/dhtclient_test.go: QmS9SiLAojXYobqV9m5yeRpyPzt6JcSbQD78RNvSp6LPx6
dht/dhtclient/options.go: QmaoJiavHescgx98inQjVUipPFRvcFFrodrScZ3fvrXJ4z
Expand Down
2 changes: 1 addition & 1 deletion packages/hashes.csv
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fetchai/connections/http_server,QmWdLqcqD4zgdCRr3hYHDQ9ywkqkPigeBkK8jteaS9a5th
fetchai/connections/ledger,QmTZaSmup7zcKwxr3k6yAT51zEKnmYowDhXpPVva7aC55i
fetchai/connections/local,QmdbDffq5yzKhGdJpFdj5Bx4jepZYLoZNPRLEhucWtTNfB
fetchai/connections/oef,Qmdz7XTS4pmaHLXhg3kfxCgDjayRJxL9ixxG9AfpxyPWyr
fetchai/connections/p2p_libp2p,QmSnKzqAQrgPsEiJ99YbYjsMkpNvm5fBS53vpCc52iKZeQ
fetchai/connections/p2p_libp2p,QmRhk1k9GhGknptkSRuaXMZMXsXBqqYN3HnDjFRjiXAUsZ
fetchai/connections/p2p_libp2p_client,Qmdnz1kBA31EuUTxRSiLCWt7D6v8j7t4v2zQwaASLr91r8
fetchai/connections/p2p_stub,Qma1A5oePh2K66QNHu7vfamAvBjMwKXgdgAdmu27YRZny8
fetchai/connections/prometheus,Qmd4nVwPNGDVjsjL6EuS4xcnLCr3mRiQcFuW9snZ9qPrYs
Expand Down
3 changes: 3 additions & 0 deletions tests/test_configurations/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ def test_compare_data_pattern():
== "For attribute `a` `str` data type is expected, but `int` was provided!"
)

errors = validate_data_with_pattern({"a": None}, {"a": int})
assert not errors

assert not validate_data_with_pattern(
{"a": 12}, {"a": "${var}"}, skip_env_vars=True
)
Expand Down

0 comments on commit 7ed79b3

Please sign in to comment.