babblebot-server / babblebot-server/server

When Adding a plugin to the system, there is no validation check on plugin file

Open
#283 0 comments 0 reactions 0 assignees View on GitHub
bug good first issue
Dominant language
Java
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

## Bug Report

### Description

When Adding a plugin to the system, there is no validation check on plugin file

### How-to reproduce

Steps to reproduce the behavior:
1. POST 'http://url/v1/plugins' with an empty plugin file

### Expected Behaviour
The system to spit out an validation error saying to provide a plugin file

### Actual Behaviour
The error received was
```json {"uniqueId":"ef0e49ed-e519-4138-bc7e-26cdbba6f9a6","exchangeTime":14,"status":500,"message":"Something went wrong, please check the logs Request-ID: [ef0e49ed-e519-4138-bc7e-26cdbba6f9a6]"} ```

### Logs
```
java.lang.NullPointerException: Cannot invoke "org.springframework.web.multipart.MultipartFile.getBytes()" because the return value of "net.bdavies.babblebot.dto.CreatePluginRequest.getPlugin()" is null

at net.bdavies.babblebot.service.PluginService.lambda$createPlugin$1(PluginService.java:82) ~[babblebot-server-server-3.0.0-rc.22.jar:na]

at net.bdavies.babblebot.api.dto.ResponseBag.from(ResponseBag.java:63) ~[babblebot-server-api-3.0.0-rc.22.jar:na]

at net.bdavies.babblebot.service.PluginService.createPlugin(PluginService.java:67) ~[babblebot-server-server-3.0.0-rc.22.jar:na]

at net.bdavies.babblebot.controller.PluginController.createPlugin(PluginController.java:54) ~[babblebot-server-server-3.0.0-rc.22.jar:na]
```

### Possible Solution
Add validation to the CreatePluginRequest class

### Enviroment



Java Version: 17
BabbleBot-Server Version: 3.0.0-rc.22
Plugins installed: n/a

Related Config Settings: n/a

Contributor guide

Open the contributing guide

Research direction

Start with CreatePluginRequest and the POST handler in PluginController.java, then inspect PluginService.java around lines 67 and 82 where the null plugin reaches getBytes(). Confirm how request validation errors are represented, and verify that an empty plugin request produces a validation response instead of the logged 500 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.