Repository navigation
Feature/issue195 - #224
Feature/issue195#224
Conversation
Implement CBOM delete endpoint
…pload" to "manual-upload+ID"
|
I did not see that signing is required for this project, sorry! Should I rebase and make another PR or is it not that important? |
There was a problem hiding this comment.
Hi @fynnth,
Thanks a lot for your PR! I partially tested it with the the built-in Swagger UI and, unfortunately, it does not quite work as expected. Here is what I did:
I have a local CBOMkit instance running with a few CBOMs in its inventory. I tested your DELETE and GET endpoints. The strategy was first to delete a certain CBOM by its identifier so that a subsequent GET call for this identifier shouldn't return a result (because the CBOM has been deleted).
The DELETE call returned a 200 {"status":"CBOM deleted"}. This looked promising but the GET call got stuck and never returned.
I checked the logs and saw:
2025-06-11 11:05:22,849 INFO [com.ibm.inf.CommandBus] (executor-thread-1) sending command DeleteCBOMCommand[projectIdentifier=pkg:maven/com.fasterxml.jackson.core/[email protected]?type=jar]
2025-06-11 11:05:22,850 ERROR [com.ibm.inf.CommandBus] (pool-8-thread-3) Invalid command type
I checked the database and the deletion did not happen despite the success message. The error message indicates that the command handler registration didn't work and hence we get an "Invalid command type" error (and nothing has been deleted).
Please take a look at the com.ibm.usecases.database.queries.ListStoredCBOMsQueryHandler class which implements the command handler for the /api/v1/cbom/last/{limit} endpoint. This contains an onStart method which registers the handler with the IQuery bus. If you implement your handlers this way you also don't have to explicitly inject them as you did in the CBOMResource class (and hence no dummy objects). In fact, the ListStoredCBOMsQueryHandler gets created and registered implicitly and it's never used directly in our code.
You can easily test your PR via Swagger. The URL would be (http://localhost:8081/q/swagger-ui/) if you run the backend locally.
That's ok. |
|
Hi @san-zrl, Thanks for the quick check! However, it seems like the GET method always hangs when called with a non-existent ID. I’ve completely restarted the database and rebuilt everything from scratch, and when I try to GET an ID that doesn’t exist, that seems to be the default behavior for me — after that, Swagger keeps loading indefinitely, and the command line shows the same behavior. Also, the DELETE method doesn’t return a 404 when the identifier doesn’t exist (which I will fix), but it does remove existing entries from the CBOMReadModel table on my system.
I’m a bit unsure about what caused the deletion to fail on your side — could you check again whether URL encoding was the issue? Also is the behavior of the GET function only like this for me? |
|
Hi @fynnth , I have to correct myself - it's a bit more complex. I don't think the problem is related to URL encoding since swagger does that for us AFAIK. I only tested via swagger and this is the behavior I see:
|
… wrong logging Output for Commands
|
Hi @san-zrl, I think the latest commit should fix the problems by:
For me everything runs through without any errors or wrong logging messages. I tested all implemented endpoints with swagger and with the commandline. Since I made changes to the QueryBus please check that those do not disrupt any other functionality that might use it. |
|
Hi @fynnth - Thanks a lot for the update and the work you put into this PR. I tested
try {
byte[] cbomBytes = cbomString.getBytes(StandardCharsets.UTF_8);
Parser parser = BomParserFactory.createParser(cbomBytes);
Bom cycloneDXbom = parser.parse(cbomBytes);
} catch (ParseException e) {
// send response code 400
}
"metadata": {
"timestamp": "2025-06-12T09:00:41Z",
"properties": [
{
"name": "gitUrl",
"value": "https://github.com/FasterXML/jackson-core"
},
{
"name": "revision",
"value": "2.13.4"
},
{
"name": "commit",
"value": "e9598e5"
},
{
"name": "subfolder",
"value": ""
}
]
}The metadata are located at top level of the BOM object. Thy can be accessed very easily via the |
|
Hi @san-zrl , I've refined the POST method and tested it with several CBOMs and SBOMs I had on my laptop. Please check whether the changes in the latest commit align with what you had in mind and if it works well for you. |
|
Hi @fynnth - great work! Thank you very much once again. |




Implements the Endpoints from #195. Please check carefully if that fits your expectations regarding this issue, since I have no experience as a java developer.
I took the freedom and decided that manual uploads with POST will be marked with "manual-upload-{UUID}" where the UUID is the same as the id of the entry. I hope that fits with you, otherwise please change it to whatever you like. Also no real unit-tests were done, so there might be some unforseen bugs.