Closing a bulk fails for SCThingTypes that contain a space character

Summary

If on a bulk for a SCThingType, that contains a space character, is called done the backend throws the following UnhandledPromiseRejectionWarning:

backend_1           | (node:1) UnhandledPromiseRejectionWarning: [invalid_alias_name_exception] Invalid alias name [academic event]: must not contain the following characters [ , ", *, \, <, |, ,, >, /, ?] :: {"path":"/_aliases","query":{},"body":"{\"actions\":[{\"add\":{\"index\":\"stapps_academic_event_test_122be754\",\"alias\":\"academic event\"}}]}","statusCode":400,"response":"{\"error\":{\"root_cause\":[{\"type\":\"invalid_alias_name_exception\",\"reason\":\"Invalid alias name [academic event]: must not contain the following characters [ , \\\", *, \\\\, <, |, ,, >, /, ?]\"}],\"type\":\"invalid_alias_name_exception\",\"reason\":\"Invalid alias name [academic event]: must not contain the following characters [ , \\\", *, \\\\, <, |, ,, >, /, ?]\"},\"status\":400}"}
backend_1           |     at respond (/app/node_modules/elasticsearch/src/lib/transport.js:308:15)
backend_1           |     at checkRespForFailure (/app/node_modules/elasticsearch/src/lib/transport.js:267:7)
backend_1           |     at HttpConnector.<anonymous> (/app/node_modules/elasticsearch/src/lib/connectors/http.js:166:7)
backend_1           |     at IncomingMessage.wrapper (/app/node_modules/lodash/lodash.js:4935:19)
backend_1           |     at IncomingMessage.emit (events.js:194:15)
backend_1           |     at endReadableNT (_stream_readable.js:1103:12)
backend_1           |     at process._tickCallback (internal/process/next_tick.js:63:19)
backend_1           | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)

And the response contains status 204.

Steps to reproduce

  1. Create a bulk with:
{
	"expiration": "2019-06-24T12:37:38+02:00",
	"type": "academic event",
	"source": "test"
}
  1. Call done for the resulting bulk.

Example Project

Which version of the software did you use ?

registry.gitlab.com/openstapps/backend/ks-ug:master

What is the current bug behavior?

Bulk is not getting closed.

What is the expected correct behavior?

Bulk should be closed.

Relevant logs and/or screenshots

  • docker-compose.yml
version: '2'
services:
  database:
    image: registry.gitlab.com/openstapps/database:master
    volumes:
      - ./database:/usr/share/elasticsearch/data
    expose:
      - "9200"
  backend:
    image: registry.gitlab.com/openstapps/backend/ks-ug:master
    # build: ../others/backend/.
    environment:
      ES_PORT_9200_TCP_ADDR: database
      ES_PORT_9200_TCP_PORT: 9200
      SMTPALLOWFAILURE: "true"
      ALLOW_NO_TRANSPORT: "true"
      NODE_CONFIG_ENV: "elasticsearch"
      NODE_APP_INSTANCE: "default"
      NODE_ENV: "production"
      STAPPS_LOG_LEVEL: 31
    extends:
      file: logging.yml
      service: logger_smtp
    expose:
      - "3000"
    ports:
      - 3000:3000
    depends_on:
      - database
    labels:
      - stapps.version=1.0.0

Possible fixes

Edited by Sebastian Lange