DuniterPy issueshttps://git.duniter.org/clients/python/duniterpy/-/issues2023-06-30T09:03:32+02:00https://git.duniter.org/clients/python/duniterpy/-/issues/204jsonchema bump to v4 (2020-12 draft) breaks bma.blockchain.difficulties2023-06-30T09:03:32+02:00Mouljsonchema bump to v4 (2020-12 draft) breaks bma.blockchain.difficulties### Problem
Since [`jsonschema` bump from v3 to v4](e56163667dc77f609b70cf6c15c5191377860733), at least `bma.blockchain.difficulties` throws [the error in this post](https://github.com/python-jsonschema/jsonschema/issues/852#issuecomment...### Problem
Since [`jsonschema` bump from v3 to v4](e56163667dc77f609b70cf6c15c5191377860733), at least `bma.blockchain.difficulties` throws [the error in this post](https://github.com/python-jsonschema/jsonschema/issues/852#issuecomment-933376870).
<details><summary>Error</summary>
```sh
>>> from duniterpy.api import bma
>>> from duniterpy.api.client import Client
>>> c = Client("BMAS g1.duniter.org 443")
>>> c(bma.blockchain.difficulties)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/work/u23a14/ML/duniterpy/duniterpy/api/client.py", line 442, in __call__
return _function(self, *args, **kwargs)
File "/work/u23a14/ML/duniterpy/duniterpy/api/bma/blockchain.py", line 330, in difficulties
return client.get(f"{MODULE}/difficulties", schema=DIFFICULTIES_SCHEMA)
File "/work/u23a14/ML/duniterpy/duniterpy/api/client.py", line 359, in get
return client.request_url(
File "/work/u23a14/ML/duniterpy/duniterpy/api/client.py", line 274, in request_url
parse_response(content, schema)
File "/work/u23a14/ML/duniterpy/duniterpy/api/client.py", line 89, in parse_response
jsonschema.validate(data, schema)
File "/home/u23a14/.cache/pypoetry/virtualenvs/duniterpy-3m7gpsy_-py3.10/lib/python3.10/site-packages/jsonschema/validators.py", line 1117, in validate
cls.check_schema(schema)
File "/home/u23a14/.cache/pypoetry/virtualenvs/duniterpy-3m7gpsy_-py3.10/lib/python3.10/site-packages/jsonschema/validators.py", line 231, in check_schema
raise exceptions.SchemaError.create_from(error)
jsonschema.exceptions.SchemaError: [{'type': 'object', 'properties': {'uid': {'type': 'string'}, 'level': {'type': 'number'}}, 'required': ['uid', 'level']}] is not of type 'object', 'boolean'
Failed validating 'type' in metaschema['allOf'][1]['properties']['properties']['additionalProperties']['$dynamicRef']['allOf'][1]['properties']['items']['$dynamicRef']['allOf'][0]:
{'$defs': {'anchorString': {'pattern': '^[A-Za-z_][-A-Za-z0-9._]*$',
'type': 'string'},
'uriReferenceString': {'format': 'uri-reference',
'type': 'string'},
'uriString': {'format': 'uri', 'type': 'string'}},
'$dynamicAnchor': 'meta',
'$id': 'https://json-schema.org/draft/2020-12/meta/core',
'$schema': 'https://json-schema.org/draft/2020-12/schema',
'$vocabulary': {'https://json-schema.org/draft/2020-12/vocab/core': True},
'properties': {'$anchor': {'$ref': '#/$defs/anchorString'},
'$comment': {'type': 'string'},
'$defs': {'additionalProperties': {'$dynamicRef': '#meta'},
'type': 'object'},
'$dynamicAnchor': {'$ref': '#/$defs/anchorString'},
'$dynamicRef': {'$ref': '#/$defs/uriReferenceString'},
'$id': {'$comment': 'Non-empty fragments not allowed.',
'$ref': '#/$defs/uriReferenceString',
'pattern': '^[^#]*#?$'},
'$ref': {'$ref': '#/$defs/uriReferenceString'},
'$schema': {'$ref': '#/$defs/uriString'},
'$vocabulary': {'additionalProperties': {'type': 'boolean'},
'propertyNames': {'$ref': '#/$defs/uriString'},
'type': 'object'}},
'title': 'Core vocabulary meta-schema',
'type': ['object', 'boolean']}
On schema['properties']['levels']['items']:
[{'properties': {'level': {'type': 'number'},
'uid': {'type': 'string'}},
'required': ['uid', 'level'],
'type': 'object'}]
```
</details>
### JSON Drafts
From what I understood, [v4 introduced `2020-12` and `2019-09` drafts](https://github.com/python-jsonschema/jsonschema/blob/main/CHANGELOG.rst#v400) and therefore [the last one supported becomes default](https://python-jsonschema.readthedocs.io/en/stable/validate/#the-basics).
These drafts are JSON specifications for `jsonschema` schemas.
### BMA
I quickly checked the other `bma` `GET` requests, and they seem to work. We don’t have (integration) tests checking that the `GET` requests are still working.
`bma.blockchain.difficulties` does not support `2020-12` draft, but supports previous ones.
This seems to be only affecting `bma.blockchain.DIFFICULTIES_SCHEMA` since it’s the only one declaring `"items": []` `items` with a list. I would fix this one by using `prefixItems` as stated in [this ticket](https://github.com/python-jsonschema/jsonschema/issues/852#issuecomment-933376870).
### Solutions
We have these choices:
- switch back to `jsonschema` v3.2.0, but, I would prefer the latter to keep the latest `jsonschema` version
- In `DIFFICULTIES_SCHEMA`:
- set `"$schema": jsonschema.Draft7Validator.META_SCHEMA["$id"],`
- remove the list `[]` wrapping, not sure if this is correct
- set `prefixItems`
### References
- https://json-schema.org/draft/2020-12/release-notes.html#changes-to-items-and-additionalitems
- https://python-jsonschema.readthedocs.io/en/stable/faq/#my-schema-specifies-format-validation-why-do-invalid-instances-seem-valid1.2.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/201Support BMA changes2023-06-06T21:53:33+02:00MoulSupport BMA changes### Sources and transactions retrieval
- nodes/typescript/duniter!1420+:
- `/tx/sources/$pubkey`
- `/tx/sources/$pubkey/pending`
- `/tx/history/$pubkey/`: nodes/typescript/duniter!1425+
- [x] jsonschema: `HISTORY_SCHEMA` set `receivi...### Sources and transactions retrieval
- nodes/typescript/duniter!1420+:
- `/tx/sources/$pubkey`
- `/tx/sources/$pubkey/pending`
- `/tx/history/$pubkey/`: nodes/typescript/duniter!1425+
- [x] jsonschema: `HISTORY_SCHEMA` set `receiving` as non required since the field was removed (also removed from Duniter v1.9)
### Wot: Support to pass `?pubkey` query
- Defaulting `pubkey_query` to:
- `True` would be breaking change when passing a `uid`, but would allow to use the optimization by default
- `False` would not be a breaking change, but requires a change to get the optimization: I go for this option
- `/wot/requirements/$pubkey?pubkey`: nodes/typescript/duniter!1422+
- nodes/typescript/duniter!1423+:
- `/wot/certifiers-of/$pubkey?pubkey`
- `/wot/certified-by/$pubkey?pubkey`
### `node/summary` storage
In `/node/summary` new fields can be added to the jsonschema, but do not set them as mandatory since it would break the backward compatibility
- nodes/typescript/duniter!1424+1.2.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/170Endpoints' regex improvement2021-07-22T18:27:29+02:00MoulEndpoints' regex improvement- [x] Change host regex, to support IDN: Internationalized domain names
- [x] Define more compact ipv6 and ipv4 regex
- [x] Define port regex
- [x] Name capturing groups
- [x] Fix/overcome server/host and ipv4 mix up with BMA(S) and GVA ...- [x] Change host regex, to support IDN: Internationalized domain names
- [x] Define more compact ipv6 and ipv4 regex
- [x] Define port regex
- [x] Name capturing groups
- [x] Fix/overcome server/host and ipv4 mix up with BMA(S) and GVA endpoints1.0.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/139Rename Endpoints attributes from server to host(name)2021-06-29T18:58:02+02:00MoulRename Endpoints attributes from server to host(name)In `Endpoint`s classes, rename `server` attribute to `host` or `hostname`.
`ConnectionHandler`’s `server` attribute is used as an alias and can contains a domain name, an ipv6, and an ipv4. Could be renamed as `address`. `server` is qui...In `Endpoint`s classes, rename `server` attribute to `host` or `hostname`.
`ConnectionHandler`’s `server` attribute is used as an alias and can contains a domain name, an ipv6, and an ipv4. Could be renamed as `address`. `server` is quite fine.1.0.0MoulMoulhttps://git.duniter.org/clients/python/duniterpy/-/issues/36Request data example is not working2020-06-06T20:26:59+02:00MoulRequest data example is not workinghttps://github.com/duniter/duniter-python-api/wiki/Request-data is not working
```python
python3 test.py
Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7f0b62d151d0>
Trace...https://github.com/duniter/duniter-python-api/wiki/Request-data is not working
```python
python3 test.py
Creating a client session outside of coroutine
client_session: <aiohttp.client.ClientSession object at 0x7f0b62d151d0>
Traceback (most recent call last):
File "test.py", line 44, in <module>
asyncio.get_event_loop().run_until_complete(main())
File "/usr/lib64/python3.5/asyncio/base_events.py", line 387, in run_until_complete
return future.result()
File "/usr/lib64/python3.5/asyncio/futures.py", line 274, in result
raise self._exception
File "/usr/lib64/python3.5/asyncio/tasks.py", line 239, in _step
result = coro.send(None)
File "test.py", line 29, in main
response = await bma.node.Summary(connection).get(AIOHTTP_SESSION)
AttributeError: module 'duniterpy.api.bma.node' has no attribute 'Summary'
```https://git.duniter.org/clients/python/duniterpy/-/issues/114Fix bma.blockhain.revoked calling /blockchain/with/excluded2020-04-26T14:55:17+02:00MoulFix bma.blockhain.revoked calling /blockchain/with/excluded7d822aee introduced a new method [`bma.blockchain.revoked` which is exactly the same as `bma.blockchain.excluded`](https://git.duniter.org/clients/python/duniterpy/blob/88107ff04c24c2c6a9c7ab2b1c7526be92dd5149/duniterpy/api/bma/blockchai...7d822aee introduced a new method [`bma.blockchain.revoked` which is exactly the same as `bma.blockchain.excluded`](https://git.duniter.org/clients/python/duniterpy/blob/88107ff04c24c2c6a9c7ab2b1c7526be92dd5149/duniterpy/api/bma/blockchain.py#L394-411) based on `/blockchain/with/excluded`.
Its a bug, cause the blockchain/with/revoked should be called.0.57.0Vincent TexierVincent Texierhttps://git.duniter.org/clients/python/duniterpy/-/issues/122Implement /wot/requirements-of-pending support in BMA2020-04-02T18:26:06+02:00MoulImplement /wot/requirements-of-pending support in BMA- [x] Implement it support
- [x] Also [document it](https://git.duniter.org/nodes/typescript/duniter/blob/dev/doc/HTTP_API.md#contents)- [x] Implement it support
- [x] Also [document it](https://git.duniter.org/nodes/typescript/duniter/blob/dev/doc/HTTP_API.md#contents)0.57.0Vincent TexierVincent Texierhttps://git.duniter.org/clients/python/duniterpy/-/issues/65Not possible to use blockchain/with/*2019-06-05T17:01:38+02:00MoulNot possible to use blockchain/with/*```bash
blockswithud = await client(blockchain.with.ud)
^
SyntaxError: invalid syntax
```
Because of `with` keyword.```bash
blockswithud = await client(blockchain.with.ud)
^
SyntaxError: invalid syntax
```
Because of `with` keyword.0.51.0Vincent TexierVincent Texierhttps://git.duniter.org/clients/python/duniterpy/-/issues/11Crash when node does not return json data2019-01-15T00:03:39+01:00insoCrash when node does not return json dataReference : https://github.com/ucoin-io/cutecoin/issues/235
Reference : https://github.com/ucoin-io/cutecoin/issues/235
https://git.duniter.org/clients/python/duniterpy/-/issues/12Parsing version field2019-01-15T00:03:14+01:00insoParsing version fieldThe version field is sometimes an int, sometime a string. Should be parsed the same for every request.
The version field is sometimes an int, sometime a string. Should be parsed the same for every request.