tarantool / tarantool/tarantool

Make space.create params error less vague

Open
#6,742 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
Lua
Stars
3.7k
Forks
419
Avg merge
1d 23h
Merged PRs (30d)
88

Description

Is your feature request related to a problem? Please describe.

I've tried to build a simple space for tests. It is a bit painful to debug :eval calls, and it's even more painful if error is vague.

My code was

if not box.cfg.read_only then
    local sp = box.schema.space.create(space_name, {
        {name = 'id', type = 'unsigned'},
        {name = 'bucket_id', type = 'unsigned'},
    })
    -- create index, etc...
end

and I've got an error Illegal parameters, unexpected option '1'. I've spent some time to get what's this one was about. My mistake was to call with { { name = ... } } as opts instead of { format = {{ name = ... }} }, but it wasn't obvious. Like, there is no explicit 1s in my code.

Describe the solution you'd like

I think an error message You should provide map with options instead of array or Expected opts format is { format = {...}, ... } would be more convenient to interpret.

Describe alternatives you've considered

Not sure there's any.

Additional context

I think provided info should be enough.

Definition of Done

Less vague error message is case of providing array for opts instead of a map.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing box.schema.space.create and its options validation, focusing on the case where opts is an array rather than a map. Review how the :eval call reports the unexpected option, then verify that this input produces a message identifying the expected { format = {...}, ... } structure.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.