Graylog2/graylog2-server

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

Open

#4,666 创建于 2018年3月18日

在 GitHub 查看
 (2 评论) (0 反应) (0 负责人)Java (1,032 fork)batch import
buggood first issuetriaged

仓库指标

Star
 (6,945 star)
PR 合并指标
 (平均合并 8天 19小时) (30 天内合并 297 个 PR)

描述

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

{
  "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.

{
  "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.

---
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

贡献者指南