mirror of
https://github.com/dragonchain/dragonchain.git
synced 2025-08-29 00:02:53 -04:00
Give better schema errors with bad input (#214)
* better schema errors * update redis
This commit is contained in:
parent
5e7d3b9e64
commit
0ebba6cb16
@ -4,6 +4,7 @@
|
||||
|
||||
- **Feature:**
|
||||
- Default error reporting to save to disk, so that crash logs/tracebacks can be automatically saved.
|
||||
- Provide better error message when bad input to api doesn't match required schemas
|
||||
- **Bugs:**
|
||||
- Fix a bug where getting the cached list of verifications for a block would always fail
|
||||
- Fix a bug where existing interchain networks could be overwritten if trying to create a new network with the same blockchain and name
|
||||
@ -15,7 +16,7 @@
|
||||
- Change dragonchain deployment docs to reflect helm install changes from helm repository with pinned version
|
||||
- Stop posting helm chart directly to docs
|
||||
- **Packaging:**
|
||||
- Update aioredis, docker, boto3, web3, and aiohttp dependencies
|
||||
- Update aioredis, docker, boto3, web3, redis, fastjsonschema, and aiohttp dependencies
|
||||
- Update helm chart to use a pinned container version by default
|
||||
- Use a helm chart repository for helm distribution
|
||||
- **Development:**
|
||||
|
@ -52,8 +52,8 @@ def create_api_key_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
body = flask.request.json
|
||||
try:
|
||||
_validate_api_key_creation_v1(body)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
nickname = body.get("nickname") or ""
|
||||
|
||||
return helpers.flask_http_response(201, api_keys.create_api_key_v1(nickname))
|
||||
@ -97,8 +97,8 @@ def update_api_key_v1(key_id: str) -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_api_key_update_v1(body)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
api_keys.update_api_key_v1(key_id, body["nickname"])
|
||||
return helpers.flask_http_response(200, helpers.format_success(True))
|
||||
|
@ -82,8 +82,8 @@ def enqueue_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_broadcast_schema_v1(content)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("Input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
dragonnet.enqueue_item_for_verification_v1(content, deadline)
|
||||
return helpers.flask_http_response(200, helpers.format_success(True))
|
||||
@ -100,8 +100,8 @@ def dragonnet_auth_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_interchain_auth_v1(body)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("Request body did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
dragonnet.register_interchain_auth_v1(body)
|
||||
return helpers.flask_http_response(201, helpers.format_success(True))
|
||||
|
@ -77,8 +77,8 @@ def create_bitcoin_interchain_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_bitcoin_network_create_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(201, interchain.create_bitcoin_interchain_v1(data))
|
||||
|
||||
@ -90,8 +90,8 @@ def create_ethereum_interchain_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_ethereum_network_create_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(201, interchain.create_ethereum_interchain_v1(data))
|
||||
|
||||
@ -103,8 +103,8 @@ def update_bitcoin_interchain_v1(name: str) -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_bitcoin_network_update_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.update_bitcoin_interchain_v1(name, data))
|
||||
|
||||
@ -116,8 +116,8 @@ def update_ethereum_interchain_v1(name: str) -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_ethereum_network_update_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.update_ethereum_interchain_v1(name, data))
|
||||
|
||||
@ -129,8 +129,8 @@ def create_bitcoin_transaction_v1(name: str) -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_bitcoin_transaction_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.sign_interchain_transaction_v1("bitcoin", name, data))
|
||||
|
||||
@ -142,8 +142,8 @@ def create_ethereum_transaction_v1(name: str) -> Tuple[str, int, Dict[str, str]]
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_ethereum_transaction_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.sign_interchain_transaction_v1("ethereum", name, data))
|
||||
|
||||
@ -171,8 +171,8 @@ def set_default_network_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
data = flask.request.json
|
||||
try:
|
||||
_validate_set_default_interchain_v1(data)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.set_default_interchain_v1(data["blockchain"], data["name"]))
|
||||
|
||||
@ -205,8 +205,8 @@ def public_blockchain_transaction_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
elif data["network"] in ["ETH_MAINNET", "ETH_ROPSTEN", "ETC_MAINNET", "ETC_MORDEN"]:
|
||||
_validate_ethereum_transaction_v1(data.get("transaction"))
|
||||
else:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
raise exceptions.ValidationException("Invalid network provided")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(200, interchain.legacy_sign_blockchain_transaction_v1(data["network"], data["transaction"]))
|
||||
|
@ -89,8 +89,8 @@ def post_contract_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
_validate_sc_create_v1(contract)
|
||||
if contract.get("custom_indexes"):
|
||||
helpers.verify_custom_indexes_options(contract.get("custom_indexes"))
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(202, smart_contracts.create_contract_v1(contract))
|
||||
|
||||
@ -105,8 +105,8 @@ def update_contract_v1(contract_id: str) -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_sc_update_v1(update)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(202, smart_contracts.update_contract_v1(contract_id, update))
|
||||
|
||||
|
@ -57,8 +57,8 @@ def register_transaction_type_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
_validate_create_txn_type_v1(content)
|
||||
if content.get("custom_indexes"):
|
||||
helpers.verify_custom_indexes_options(content["custom_indexes"])
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
transaction_types.register_transaction_type_v1(content)
|
||||
return helpers.flask_http_response(200, helpers.format_success(True))
|
||||
|
@ -50,8 +50,8 @@ def post_transaction_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_txn_create_v1(txn)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
return helpers.flask_http_response(201, transactions.submit_transaction_v1(txn, flask.request.headers.get("X-Callback-URL")))
|
||||
|
||||
@ -68,8 +68,8 @@ def post_transaction_bulk_v1() -> Tuple[str, int, Dict[str, str]]:
|
||||
|
||||
try:
|
||||
_validate_bulk_txn_create_v1(content)
|
||||
except fastjsonschema.JsonSchemaException:
|
||||
raise exceptions.ValidationException("User input did not match JSON schema")
|
||||
except fastjsonschema.JsonSchemaException as e:
|
||||
raise exceptions.ValidationException(str(e))
|
||||
|
||||
response = transactions.submit_bulk_transaction_v1(content)
|
||||
if not response["201"]:
|
||||
|
@ -1,16 +1,16 @@
|
||||
boto3==1.9.243
|
||||
redis==3.3.8
|
||||
boto3==1.9.247
|
||||
redis==3.3.10
|
||||
apscheduler==3.6.1
|
||||
jsonpath==0.82
|
||||
Flask==1.1.1
|
||||
requests==2.22.0
|
||||
fastjsonschema==2.13
|
||||
fastjsonschema==2.14.1
|
||||
secp256k1==0.13.2
|
||||
web3==5.2.0
|
||||
kubernetes==10.0.1
|
||||
docker==4.1.0
|
||||
gunicorn[gevent]==19.9.0
|
||||
aiohttp[speedups]==3.6.1
|
||||
aiohttp[speedups]==3.6.2
|
||||
aioredis==1.3.0
|
||||
base58==1.0.3
|
||||
bit==0.6.0
|
||||
|
Loading…
x
Reference in New Issue
Block a user