Graylog2 / Graylog2/graylog2-server

Create Index Set API returns 500 error when invalid id is included in the request body.

Open
#4,666 2 comments 0 reactions 0 assignees View on GitHub
bug good first issue triaged
Dominant language
Java
Stars
8.1k
Forks
1.1k
Avg merge
1d 20h
Merged PRs (30d)
217

Description

Create Index Set API returns 500 error when invalid id is included in the request body.

This issue may be related to https://github.com/Graylog2/graylog2-server/issues/1718 .

## Expected Behavior

Returns 400 error and appropriate error message.

## Current Behavior

```json
{
"type": "ApiError",
"message": "Error mapping BSON to POJOs"
}
```

Response Code: 500

## Possible Solution

## Steps to Reproduce (for bugs)

Run a Index Set Create API request whose id parameter is invalid.
It is convenient to use the API browser.

http://localhost:9000/api/api-browser#!/System/IndexSets/save_post_1

Show the sample request body.

```json
{
"id": "invalid id",
"title": "Default index set",
"description": "The Graylog default index set",
"index_prefix": "ggg",
"shards": 4,
"replicas": 0,
"rotation_strategy_class": "org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategy",
"rotation_strategy": {
"type": "org.graylog2.indexer.rotation.strategies.MessageCountRotationStrategyConfig",
"max_docs_per_index": 20000000
},
"retention_strategy_class": "org.graylog2.indexer.retention.strategies.DeletionRetentionStrategy",
"retention_strategy": {
"type": "org.graylog2.indexer.retention.strategies.DeletionRetentionStrategyConfig",
"max_number_of_indices": 20
},
"creation_date": "2018-02-20T11:37:19.305Z",
"index_analyzer": "standard",
"index_optimization_max_num_segments": 1,
"index_optimization_disabled": false,
"writable": true,
"default": false
}
```

## Context

## Your Environment

* Graylog Version: 2.4.3-1
* Elasticsearch Version: 5.6.3
* MongoDB Version: 3
* Operating System: Mac OS X
* Browser version: Google Chrome 65.0.3325.162 (Official Build) (64 bit)

Show the docker-compose.yml which I use.

```yaml
---
version: '2'
services:
# MongoDB: https://hub.docker.com/_/mongo/
mongodb:
image: mongo:3
# Elasticsearch: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docker.html
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:5.6.3
environment:
- http.host=0.0.0.0
- transport.host=localhost
- network.host=0.0.0.0
# Disable X-Pack security: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/security-settings.html#general-security-settings
- xpack.security.enabled=false
- "ES_JAVA_OPTS=-Xms1024m -Xmx1024m"
ulimits:
memlock:
soft: -1
hard: -1
mem_limit: 2g
# Graylog: https://hub.docker.com/r/graylog/graylog/
graylog:
image: graylog/graylog:2.4.3-1
environment:
# CHANGE ME!
- GRAYLOG_PASSWORD_SECRET=somepasswordpepper
# Password: admin
- GRAYLOG_ROOT_PASSWORD_SHA2=8c6976e5b5410415bde908bd4dee15dfb167a9c873fc4bb8a81f6f2ab448a918
- GRAYLOG_WEB_ENDPOINT_URI=http://127.0.0.1:9000/api
links:
- mongodb:mongo
- elasticsearch
depends_on:
- mongodb
- elasticsearch
ports:
# Graylog web interface and REST API
- 9000:9000
# GELF TCP
- 12201:12201
# GELF UDP
- 12201:12201/udp
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.