NOCODB container crashes when inserting a record

Hi everyone. I’m having this issue: when writing a record to a MySQL table via the NOCODB v3 API, the container crashes. The Docker logs show nothing except LOG [RoutesResolver]. Here’s my Golang code that inserts the record:

// =========================================================================

// CREATE

// =========================================================================

func (s *MacService) Create(mac models.MACAddress, userID int, userName string) error {

    normMac := normalizeMAC(mac.MacAddress)

    if len(normMac) == 0 {

        return fmt.Errorf("MAC-адрес не может быть пустым")

    }

    mac.MacAddress = normMac




    exists, err := s.repo.Exists(normMac, 0)

    if err != nil {

        return fmt.Errorf("ошибка проверки БД: %v", err)

    }

    if exists {

        return fmt.Errorf("MAC-адрес %s уже существует в базе", normMac)

    }




    isDomain := false

    if mac.User != nil && isSyncSource(mac.User.Source) && s.ldap != nil {

        if mac.ZUPDataID == "" {

            return fmt.Errorf("ZUP ID обязателен для официального сотрудника")

        }

        foundInAd, err := s.ldap.UserExists(mac.ZUPDataID)

        if err != nil {

            return fmt.Errorf("ошибка проверки AD: %v", err)

        }

        if foundInAd {

            isDomain = true

        } else {

            isDomain = false

            mac.DomainID = DomainNoDomainID

        }

    }




    if mac.User != nil && isSyncSource(mac.User.Source) {

        if ex, _ := s.repo.UserExists(mac.ZUPDataID); !ex {

            return fmt.Errorf("сотрудник не найден в Master-таблице")

        }

    }




    if isDomain {

        if err := s.ldap.AddMacToUser(mac.ZUPDataID, normMac); err != nil {

            return fmt.Errorf("ошибка записи в AD: %v", err)

        }

    }




    payload := []map[string]interface{}{

        {

            "mac_address":   normMac,

            "comment":       mac.Comment,

            "is_active":     mac.IsActive,

            "added_by":      userName,

            "added_by_id":   userID,

            "updated_by":    userName,

            "updated_by_id": userID,

        },

    }




    ids, err := s.nocoClient.BulkCreate(models.TableMacAddresses, payload)

    if err != nil {

        if isDomain && s.ldap != nil {

            _ = s.ldap.RemoveMacFromUser(mac.ZUPDataID, normMac)

        }

        return fmt.Errorf("ошибка API NocoDB: %v", err)

    }




    if len(ids) == 0 {

        return nil

    }

    newID := ids[0]




    if mac.DomainID != 0 {

        _ = s.nocoClient.LinkRecord(models.TableMacAddresses, models.FieldMacLinkToDomain, newID, mac.DomainID)

    }

    if mac.ZUPDataID != "" {

        _ = s.nocoClient.LinkRecord(models.TableMacAddresses, models.FieldMacLinkToZup, newID, mac.ZUPDataID)

    }




    // 7. ДЕТАЛЬНОЕ ЛОГИРОВАНИЕ (CREATE)

    go func() {




        var details []string




        // Статус

        status := "Неактивен"

        if mac.IsActive {

            status = "Активен"

        }

        details = append(details, fmt.Sprintf("Статус: %s", status))




        // Владелец

        ownerName := "Нет"

        if mac.User != nil && mac.User.Username != "" {

            ownerName = mac.User.Username

        } else if mac.ZUPDataID != "" {

            // Если пришел только ID без объекта User

            ownerName = mac.ZUPDataID

        }

        if ownerName != "Нет" {

            details = append(details, fmt.Sprintf("Владелец: %s", ownerName))

        }




        // Домен

        if mac.DomainName != "" {

            details = append(details, fmt.Sprintf("Домен: %s", mac.DomainName))

        }




        // Комментарий

        if strings.TrimSpace(mac.Comment) != "" {

            details = append(details, fmt.Sprintf("Комментарий: '%s'", mac.Comment))

        }




        // Формируем сообщение: "Admin добавил MAC [AA-BB...]: Статус: Активен; Владелец: Иванов..."

        logMessage := fmt.Sprintf("%s добавил MAC [%s]: %s", userName, normMac, strings.Join(details, "; "))




        s.logger.Log(

            "mac_address",

            newID,

            "create",

            logMessage,

            map[string]interface{}{

                "mac":     normMac,

                "details": details,

            },

            userID,

            userName,

        )

    }()




    return nil

}
func (c *NocoClient) LinkRecord(tableID, linkFieldID string, recordID int, targetID interface{}) error {




    if recordID == 0 {

        return fmt.Errorf("recordID is 0")

    }




    path := fmt.Sprintf("/api/v3/data/%s/%s/links/%s/%d", c.ProjectID, tableID, linkFieldID, recordID)




    payload := map[string]interface{}{

        "id": targetID,

    }




    resp, err := c.client.R().

        SetBody(payload).

        Post(path)




    if err != nil {

        return fmt.Errorf("сеть: %w", err)

    }




    if resp.IsError() {

        // Логируем ошибку, чтобы видеть детали

        c.logger.Error("LinkRecord Fail", "path", path, "body", resp.String())

        return fmt.Errorf("api link error: %s", resp.String())

    }




    return nil

}

In response: 2025/12/12 14:44:28 INFO Successful batch insert tableID=m6fb7qiyo72ivm4 total_created=12025/12/12 14:44:28.554752 WARN RESTY Post “http://192.168.100.164:8082/api/v3/data/p97p0j5vsq21uo1/ms79qjxpgfmzudv/records”: EOF, Attempt 1

And that’s it, the container crashes and reboots.

hello,

we have trouble replicating the issue, tested on v 0.265.1. We guess it’ll have something to do with the table schema itself and need your information on that.

  1. is the table created using API? If so, can you share the payload? Additionally, can you try create same table using web UI and check if it works?
  2. if the table is created using web UI, can you share the fields & types?
  3. can share sample payload that we can use to reproduce the issue?
  4. though it seems won’t trigger, but can try to set NC_ENABLE_ALL_API_ERROR_LOGGING=true env var and try again?
  5. is your MySQL table external db?

and FYI the request body for v3 is different than v2. It’s object (or array of object, either is fine) with the properties wrapped in field. ex:

{
  "fields": {
    "mac_address": "123.0102931313",
    "comment": "myComment", ...
  }
}

The table was created using an SQL query and then synchronized in nocodb (by the way, synchronization does not always see changes to tables if they were not from a web resource). the MySQL table is in an external database. Here is the SQL query for creating the table:

CREATE TABLE `mac_addresses` (
`id` int NOT NULL AUTO_INCREMENT,
`mac_address` varchar(17) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL COMMENT ‘XX-XX-XX-XX-XX-XX’,
`domain_id` int DEFAULT NULL COMMENT ‘Источник’,
`zupdata_id` varchar(36) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ‘GUID владельца’,
`added_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ‘Пользователь, добавивший запись’,
`updated_by` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT ‘Пользователь, обновивший запись’,
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`comment` text CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci COMMENT ‘Заметка’,
`is_active` tinyint(1) NOT NULL DEFAULT ‘1’ COMMENT ‘Флаг активности (1 - активен, 0 - неактивен)’,
`added_by_id` int DEFAULT ‘0’ COMMENT ‘ID создателя (GLPI)’,
`updated_by_id` int DEFAULT ‘0’ COMMENT ‘ID редактора (GLPI)’,
PRIMARY KEY (`id`),
KEY `idx_zupdata_active` (`zupdata_id`,`is_active`),
KEY `idx_wherefrom_active` (`domain_id`,`is_active`),
CONSTRAINT `ma_fk_zup_master` FOREIGN KEY (`zupdata_id`) REFERENCES `zup_data_master` (`id`),
CONSTRAINT `mac_addresses_ibfk_1` FOREIGN KEY (`domain_id`) REFERENCES `domain` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=7519 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT=‘Таблица MAC-адресов устройств и их владельцев’

I tried relinking the table in nocodb, but it didn’t help. The container crashes at the Link field stage.

I ran tests, and the container crashes when accessing the zup_data_master table to create a link relationship. The mac_addresses entry is created correctly, but after that, the container crashes.

|
CREATE TABLE `zup_data_master` (
`id` varchar(36) NOT NULL COMMENT 'GUID',
`username` varchar(255) DEFAULT NULL COMMENT 'ФИО',
`department` varchar(255) DEFAULT NULL COMMENT 'Подразделение',
`position` varchar(255) DEFAULT NULL COMMENT 'Должность',
`source` varchar(10) NOT NULL COMMENT 'Источник (fn, fk, gl, pta, unoff)',
`created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
KEY `idx_username` (`username`),
KEY `idx_department` (`department`),
KEY `idx_source` (`source`)

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci COMMENT='Сводная таблица данных сотрудников из всех источников'

I’ve tried to replicate the issue using this payload and it works correctly

[
  {
    "fields": {
      "mac_address": "120.31246.21313",
      "zup_data_master": [{
        "id": "1"
      }]
    }
  }
]

can you verify whether something happen using curl, insomnia or postman to call the API? And then share the payload here?

1 Like

Thanks, it all worked! I didn’t know you could do everything in one query, doing different things.

1 Like

Tell me, is it possible to cascade delete via API?