Record create failure for single digit record IDs

We have some external databases we are using with Corteza and some of these are associated together in the modules using the ‘Record selector’ type in the modules for the foreign keys in the tables. This all works great.

Because these are external tables they have their own record id’s that have already been set.

We have found that we are unable to create records associated to other tables/modules when the other table has a single digit id. The field type is a number but because the id is < 10 we receive the following error:

Error: Could not create record: invalid reference format

I think I’ve tracked this error down to the RecordValueSanitization function in the record.go file.

It looks like it’s checking for a numeric using the regex ^[1-9](\d+)$ which fails for single digit numbers.

There is a Numeric regex in patterns.go that works for single digit numbers in addition to anything >= 10
Numeric string = “^[0-9]+$”

I think this is a bug and the RecordValueSanitization function should be using the regex from the Numeric in patterns.go

Wanted to post here to get your thoughts. Will post this as an issue in GitHub if that is a more appropriate place for the discussion.

Corteza version: 2023.3.4

Hi, thanks for the verbose information, this does look like a bug.

Please create an issue in the project repo so we can prioritize it, we need to do additional checks before we go changing this regex.

Thank you.

Issue created: When I try to create records that have a single digit record selector field I get an error · Issue #1418 · cortezaproject/corteza · GitHub