• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

tarantool / tarantool / 11305848171
88%

Build:
DEFAULT BRANCH: master
Ran 12 Oct 2024 01:11PM UTC
Jobs 1
Files 515
Run time 2min
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

12 Oct 2024 01:00PM UTC coverage: 87.286% (-0.003%) from 87.289%
11305848171

push

github

Totktonada
config/schema: improve unexpected array error

How it looks for a map:

NOWRAP
```lua
local schema = require('experimental.config.utils.schema')

local s = schema.new('foo', schema.map({
    key = schema.scalar({type = 'string'}),
    value = schema.scalar({type = 'string'}),
}))

s:validate({'a', 'b', 'c'})

-- Before the patch:
-- [foo] [1]: Unexpected data for scalar "string": Expected "string", got "number"

-- Now:
-- [foo] Expected a map, got an array: ["a","b","c"]
```
NOWRAP

How it looks for a record:

NOWRAP
```lua
local schema = require('experimental.config.utils.schema')

local s = schema.new('foo', schema.record({
    foo = schema.scalar({type = 'string'}),
}))

s:validate({'a', 'b', 'c'})

-- Before the patch:
-- [foo] Unexpected field "1"

-- Now:
-- [foo] Expected a record, got an array: ["a","b","c"]
```
NOWRAP

The tricky part of the patch is to determine that the given record/map
schema node never accepts a non-empty array, so we can report the error
message that is shown above.

For example, the following record/map schema nodes accept some array
values:

NOWRAP
```lua
local schema = require('experimental.config.utils.schema')

local s = schema.new('foo', schema.record({
    [1] = schema.scalar({type = 'string'}),
    [2] = schema.scalar({type = 'string'}),
    [3] = schema.scalar({type = 'string'}),
}))

s:validate({'a', 'b', 'c'}) -- OK
```
NOWRAP

NOWRAP
```lua
local schema = require('experimental.config.utils.schema')

local s = schema.new('foo', schema.map({
    key = schema.scalar({type = 'integer'}),
    value = schema.scalar({type = 'string'}),
}))

s:validate({'a', 'b', 'c'}) -- OK
```
NOWRAP

The patch implements the following criteria, when the friendly error can
be issued:

* a record has no numeric field 1
* a map has a key type that can't accept a number

The criteria covers the most typical scenarios: for example, when a
record/a map has string keys.

This change also improves error reporting of the validation step i... (continued)

69122 of 122879 branches covered (56.25%)

101917 of 116762 relevant lines covered (87.29%)

2567373.55 hits per line

Jobs
ID Job ID Ran Files Coverage
1 11305848171.1 12 Oct 2024 01:11PM UTC 0
87.29
GitHub Action Run
Source Files on build 11305848171
Detailed source file information is not available for this build.
  • Back to Repo
  • f754007e on github
  • Prev Build on master (#11295024138)
  • Next Build on master (#11326194453)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc