UCLA-IRL / ndn-python-repo

An NDN Repo implementation in Python
Apache License 2.0
16 stars 13 forks source link

delete check: wrong status code when an object contains zero-length name #78

Open yoursunny opened 9 months ago

yoursunny commented 9 months ago

Environment:

When ndn-python-repo receives a delete command that contains an ObjectParam with a Name field of TLV-LENGTH zero, the corresponding delete check command is returning top-level status 404 instead of the expected 200.

Packet trace: 1.pcapng.zip

The packet trace contains a "normal" delete command with non-zero-length name:

The packet trace contains an abnormal delete command with zero-length name:

According to NDN packet format, the zero-length name 0700 is a valid Data name. If the repo does not have a packet with this name, it should be respond in the same way as deleting a non-existent packet, i.e. like frame 20.

ndn-python-repo console output ```text [2024-02-13 15:15:39,642]INFO:Read handle: listening to / [2024-02-13 15:15:39,646]INFO:TCP insertion handle serving on ('0.0.0.0', 7376) [2024-02-13 15:15:39,648]INFO:Subscribing to topic (with interest filter): /testrepo/insert [2024-02-13 15:15:39,649]INFO:Subscribing to topic (with interest filter): /testrepo/delete [2024-02-13 15:15:43,461]INFO:received subscribed msg: /localhost/seq=1521893051/msg/testrepo/delete/%83%B25s%0F%FE%8AN [2024-02-13 15:15:43,504]INFO:Recved delete command: 39dcbd3b6a7095afb9943898aae0f9ba96fa00f5caf68ab9c2f93d390b99f4fe [2024-02-13 15:15:43,513]INFO:Deletion 39dcbd3b6a7095afb9943898aae0f9ba96fa00f5caf68ab9c2f93d390b99f4fe name=/NDNts-pyrepo/9495757 finish:0 deleted [2024-02-13 15:15:43,513]INFO:Deletion 39dcbd3b6a7095afb9943898aae0f9ba96fa00f5caf68ab9c2f93d390b99f4fe done, total 0 deleted. [2024-02-13 15:15:44,417]INFO:on_check_interest(): /testrepo/delete%20check/params-sha256=f3c2415218c93a6bc54e1606239be88cd8d3a9a6912848996fcffb55c81dd8b9 [2024-02-13 15:15:44,417]INFO:Reply to command: /testrepo/delete%20check/params-sha256=f3c2415218c93a6bc54e1606239be88cd8d3a9a6912848996fcffb55c81dd8b9 w/ code=200 [2024-02-13 15:15:44,424]INFO:received subscribed msg: /localhost/seq=1521893051/msg/testrepo/delete/%5D5%1C%B43%80%01%8F [2024-02-13 15:15:44,424]WARNING:Parameter interest blob decoding failed w/ exception: Missing name for one or more objects [2024-02-13 15:15:45,506]INFO:on_check_interest(): /testrepo/delete%20check/params-sha256=9f1925567e88c99d58a369d721e1e902bfc95ee1286e86b8a41ab2cb29f8e522 [2024-02-13 15:15:45,506]WARNING:Process does not exist for id= [2024-02-13 15:15:45,507]INFO:Reply to command: /testrepo/delete%20check/params-sha256=9f1925567e88c99d58a369d721e1e902bfc95ee1286e86b8a41ab2cb29f8e522 w/ code=404 ```
zjkmxy commented 9 months ago

The current code drops some of the requests before processing, while the spec requires it to at least mark it as MALFORMED. Let me think how to fix this. The latest commit should be able to handle empty Names.