Skip to content

Duplicate entry error for networkports_id during OCS sync when linking existing GLPI computers with OCS data #390

@vi-lgtm

Description

@vi-lgtm

I am integrating OCS Inventory NG into an existing GLPI instance that already contains computer records.
The goal is to link OCS computers to existing GLPI computers and create new GLPI computers only when they don’t exist.
During synchronization, GLPI crashes with this SQL error:

[2025-11-30 17:06:15] glpi.CRITICAL: *** Uncaught PHP Exception RuntimeException: "MySQL query error: Duplicate entry '99' for key 'networkports_id' (1062) in SQL query "INSERT INTO glpi_networkportaliases (networkports_id, date_creation, date_mod) VALUES ('99', '2025-11-30 17:06:14', '2025-11-30 17:06:14')"." at DBmysql.php line 371 Backtrace : ./src/DBmysql.php:371 ./src/DBmysql.php:1327 DBmysql->doQuery() ./src/CommonDBTM.php:776 DBmysql->insert() ./src/CommonDBTM.php:1381 CommonDBTM->addToDB() ...sinventoryng/src/Components/NetworkPort.php:184 CommonDBTM->add() ...sinventoryng/src/Components/NetworkPort.php:515 GlpiPlugin\Ocsinventoryng\Components\NetworkPort::updateNetworkPort() ...ns/ocsinventoryng/src/Components/Device.php:560 GlpiPlugin\Ocsinventoryng\Components\NetworkPort::importNetwork() ./plugins/ocsinventoryng/src/OcsProcess.php:1378 GlpiPlugin\Ocsinventoryng\Components\Device::updateDevices() ./plugins/ocsinventoryng/src/OcsProcess.php:861 GlpiPlugin\Ocsinventoryng\OcsProcess::synchronizeComputer() ./plugins/ocsinventoryng/src/OcsProcess.php:641 GlpiPlugin\Ocsinventoryng\OcsProcess::linkComputer() ./plugins/ocsinventoryng/src/OcsProcess.php:532 GlpiPlugin\Ocsinventoryng\OcsProcess::importComputer() ...ugins/ocsinventoryng/front/ocsng.import.php:119 GlpiPlugin\Ocsinventoryng\OcsProcess::processComputer() ...Glpi/Controller/LegacyFileLoadController.php:64 require() ./vendor/symfony/http-kernel/HttpKernel.php:181 Glpi\Controller\LegacyFileLoadController->__invoke() ./vendor/symfony/http-kernel/HttpKernel.php:76 Symfony\Component\HttpKernel\HttpKernel->handleRaw() ./vendor/symfony/http-kernel/Kernel.php:197 Symfony\Component\HttpKernel\HttpKernel->handle() ./public/index.php:70 Symfony\Component\HttpKernel\Kernel->handle()

However, the database already contains exactly one alias for network port ID 99:

SELECT * FROM glpi_networkportaliases WHERE networkports_id = 99;

Result:

id: 12 networkports_id: 99 networkports_id_alias: 0 date_mod: 2025-11-30 17:06:14 date_creation: 2025-11-30 17:06:14

GLPI version: 11.0.2
OCSInventoryNG plugin version: 2.1.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions