Skip to content

CURL and REST via Fetch (JavaScript/NodeJs) have different results when trying to create a type that already exists #1463

Description

@apttap

ArcadeDB Version:

ArcadeDB Server v24.1.1 (build 48e937e9a860ea97a7f245994a9df8bdb6af56d2/1707162918298/main)

OS and JDK Version:

Linux 6.2.0-33-generic - OpenJDK 64-Bit Server VM 17.0.9

Expected behavior

That it is consistent with the API via curl.

Actual behavior

Trying to create a type that already exists in JavaScript (fetch, NodeJS) yields a 500 error, while curl returns a JSON object explaining the problem.

Steps to reproduce

const result = await fetch('http://localhost:2480/api/v1/command/Test', {
    method: 'POST',
    headers: {
      'Authorization': `Basic ${Buffer.from('root:password').toString('base64')}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"language":"sql","command":"CREATE document TYPE TestType BUCKET TestBucket"}),
  });
  console.log(result.status);
  // 500
  console.log(await result.json());
  // undefined 

while a curl with the same parameters returns a response (either it already exists, or success)

curl -X POST http://localhost:2480/api/v1/command/Test \
     -d '{"language":"sql","command":"CREATE document TYPE TestType BUCKET TestBucket"}' \
     -H "Content-Type: application/json" \
     --user root:password
## {"error":"Cannot execute command","detail":"Type TestType already exists","exception":"com.arcadedb.exception.CommandExecutionException"}

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions