glpi-project / glpi

GLPI is a Free Asset and IT Management Software package, Data center management, ITIL Service Desk, licenses tracking and software auditing.
https://glpi-project.org
GNU General Public License v3.0
4.29k stars 1.29k forks source link

Inventory not working : Undefined array key "id" in /var/www/html/glpi/src/Agent.php at line 401 #14039

Closed sebma closed 1 year ago

sebma commented 1 year ago

Code of Conduct

Is there an existing issue for this?

Version

10.0.6

Bug description

Hi, The inventory is not working :

PS C:\> tail.exe -f "$env:ProgramFiles/GLPI-Agent/logs/glpi-agent.log"
   "itemtype": "Computer"
}
[Wed Feb  8 16:17:45 2023][error] [http client] communication error: 500 Internal Server Error, 
[Wed Feb  8 16:17:47 2023][debug] new thread 14 to handle task NetDiscovery

Relevant log output

/var/log/glpi$ tail -f php-errors.log
[2023-02-08 16:18:17] glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "id" in /var/www/html/glpi/src/Agent.php at line 401
  Backtrace :
  src/Inventory/Inventory.php:229                    Agent->handleAgent()
  src/Inventory/Request.php:309                      Glpi\Inventory\Inventory->contact()
  src/Inventory/Request.php:83                       Glpi\Inventory\Request->contact()
  src/Agent/Communication/AbstractRequest.php:359    Glpi\Inventory\Request->handleAction()
  src/Agent/Communication/AbstractRequest.php:271    Glpi\Agent\Communication\AbstractRequest->handleJSONRequest()
  front/inventory.php:92                             Glpi\Agent\Communication\AbstractRequest->handleRequest()
  ...tplace/glpiinventory/front/communication.php:72 include_once()
  marketplace/glpiinventory/index.php:45             include_once()

[2023-02-08 16:18:51] glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "id" in /var/www/html/glpi/marketplace/splitcat/inc/itilcategory.class.php at line 280
  Backtrace :
  marketplace/splitcat/inc/itilcategory.class.php:70 PluginSplitcatITILCategory::getItilCatSelect()
  marketplace/splitcat/ajax/splitcat.php:52          PluginSplitcatITILCategory::ajax()

The second warning is repeated multiple times.

Page URL

No response

Steps To reproduce

  1. Goto http://localhost:62354/
  2. Click on Force an Inventory
  3. Click on Back

Your GLPI setup information

Information about system installation and configuration
GLPI 10.0.6 ( => /var/www/html/glpi)
Installation mode: TARBALL
Current language:en_GB

Server
 
I was asked to remove that by my superior because it was not anonymised.

GLPI constants
 
GLPI_ROOT: "/var/www/html/glpi"
GLPI_CONFIG_DIR: "/etc/glpi/"
GLPI_VAR_DIR: "/var/lib/glpi"
GLPI_LOG_DIR: "/var/log/glpi"
GLPI_MARKETPLACE_DIR: "/var/www/html/glpi/marketplace"
GLPI_USE_CSRF_CHECK: "1"
GLPI_CSRF_EXPIRES: "7200"
GLPI_CSRF_MAX_TOKENS: "100"
GLPI_USE_IDOR_CHECK: "1"
GLPI_IDOR_EXPIRES: "7200"
GLPI_ALLOW_IFRAME_IN_RICH_TEXT: false
GLPI_SERVERSIDE_URL_ALLOWLIST: ["/^(https?|feed):\\/\\/[^@:]+(\\/.*)?$/"]
GLPI_TELEMETRY_URI: "https://telemetry.glpi-project.org"
GLPI_INSTALL_MODE: "TARBALL"
GLPI_NETWORK_MAIL: "glpi@teclib.com"
GLPI_NETWORK_SERVICES: "https://services.glpi-network.com"
GLPI_MARKETPLACE_ALLOW_OVERRIDE: true
GLPI_MARKETPLACE_MANUAL_DOWNLOADS: true
GLPI_USER_AGENT_EXTRA_COMMENTS: ""
GLPI_DISABLE_ONLY_FULL_GROUP_BY_SQL_MODE: "1"
GLPI_AJAX_DASHBOARD: "1"
GLPI_CALDAV_IMPORT_STATE: 0
GLPI_DEMO_MODE: "0"
GLPI_CENTRAL_WARNINGS: "1"
GLPI_DOC_DIR: "/var/lib/glpi"
GLPI_CACHE_DIR: "/var/lib/glpi/_cache"
GLPI_CRON_DIR: "/var/lib/glpi/_cron"
GLPI_DUMP_DIR: "/var/lib/glpi/_dumps"
GLPI_GRAPH_DIR: "/var/lib/glpi/_graphs"
GLPI_LOCAL_I18N_DIR: "/var/lib/glpi/_locales"
GLPI_LOCK_DIR: "/var/lib/glpi/_lock"
GLPI_PICTURE_DIR: "/var/lib/glpi/_pictures"
GLPI_PLUGIN_DOC_DIR: "/var/lib/glpi/_plugins"
GLPI_RSS_DIR: "/var/lib/glpi/_rss"
GLPI_SESSION_DIR: "/var/lib/glpi/_sessions"
GLPI_TMP_DIR: "/var/lib/glpi/_tmp"
GLPI_UPLOAD_DIR: "/var/lib/glpi/_uploads"
GLPI_INVENTORY_DIR: "/var/lib/glpi/_inventories"
GLPI_NETWORK_REGISTRATION_API_URL: "https://services.glpi-network.com/api/registration/"
GLPI_MARKETPLACE_PLUGINS_API_URI: "https://services.glpi-network.com/api/glpi-plugins/"
GLPI_I18N_DIR: "/var/www/html/glpi/locales"
GLPI_VERSION: "10.0.6"
GLPI_SCHEMA_VERSION: "10.0.6@21cffee0fbb5afbf0d580cabdf6fd7a922598f97"
GLPI_MARKETPLACE_PRERELEASES: false
GLPI_MIN_PHP: "7.4.0"
GLPI_MAX_PHP: "8.3.0"
GLPI_YEAR: "2023"

Libraries
 
htmlawed/htmlawed version 1.2.9 in (/var/www/html/glpi/vendor/htmlawed/htmlawed)
phpmailer/phpmailer version 6.6.0 in (/var/www/html/glpi/vendor/phpmailer/phpmailer/src)
simplepie/simplepie version 1.5.8 in (/var/www/html/glpi/vendor/simplepie/simplepie/library)
tecnickcom/tcpdf version 6.4.4 in (/var/www/html/glpi/marketplace/pdf/vendor/tecnickcom/tcpdf)
michelf/php-markdown in (/var/www/html/glpi/vendor/michelf/php-markdown/Michelf)
true/punycode in (/var/www/html/glpi/vendor/true/punycode/src)
iamcal/lib_autolink in (/var/www/html/glpi/vendor/iamcal/lib_autolink)
sabre/dav in (/var/www/html/glpi/vendor/sabre/dav/lib/DAV)
sabre/http in (/var/www/html/glpi/vendor/sabre/http/lib)
sabre/uri in (/var/www/html/glpi/vendor/sabre/uri/lib)
sabre/vobject in (/var/www/html/glpi/vendor/sabre/vobject/lib)
laminas/laminas-i18n in (/var/www/html/glpi/vendor/laminas/laminas-i18n/src)
laminas/laminas-servicemanager in (/var/www/html/glpi/vendor/laminas/laminas-servicemanager/src)
monolog/monolog in (/var/www/html/glpi/vendor/monolog/monolog/src/Monolog)
sebastian/diff in (/var/www/html/glpi/vendor/sebastian/diff/src)
donatj/phpuseragentparser in (/var/www/html/glpi/vendor/donatj/phpuseragentparser/src/UserAgent)
elvanto/litemoji in (/var/www/html/glpi/vendor/elvanto/litemoji/src)
symfony/console in (/var/www/html/glpi/vendor/symfony/console)
scssphp/scssphp in (/var/www/html/glpi/vendor/scssphp/scssphp/src)
laminas/laminas-mail in (/var/www/html/glpi/vendor/laminas/laminas-mail/src/Protocol)
laminas/laminas-mime in (/var/www/html/glpi/vendor/laminas/laminas-mime/src)
rlanvin/php-rrule in (/var/www/html/glpi/vendor/rlanvin/php-rrule/src)
blueimp/jquery-file-upload in (/var/www/html/glpi/vendor/blueimp/jquery-file-upload/server/php)
ramsey/uuid in (/var/www/html/glpi/vendor/ramsey/uuid/src)
psr/log in (/var/www/html/glpi/vendor/psr/log/Psr/Log)
psr/simple-cache in (/var/www/html/glpi/vendor/psr/simple-cache/src)
psr/cache in (/var/www/html/glpi/vendor/psr/cache/src)
league/csv in (/var/www/html/glpi/vendor/league/csv/src)
mexitek/phpcolors in (/var/www/html/glpi/vendor/mexitek/phpcolors/src/Mexitek/PHPColors)
guzzlehttp/guzzle in (/var/www/html/glpi/vendor/guzzlehttp/guzzle/src)
guzzlehttp/psr7 in (/var/www/html/glpi/vendor/guzzlehttp/psr7/src)
glpi-project/inventory_format in (/var/www/html/glpi/vendor/glpi-project/inventory_format/lib/php)
wapmorgan/unified-archive in (/var/www/html/glpi/vendor/wapmorgan/unified-archive/src)
paragonie/sodium_compat in (/var/www/html/glpi/vendor/paragonie/sodium_compat/src)
symfony/cache in (/var/www/html/glpi/vendor/symfony/cache)
html2text/html2text in (/var/www/html/glpi/vendor/html2text/html2text/src)
symfony/css-selector in (/var/www/html/glpi/vendor/symfony/css-selector)
symfony/dom-crawler in (/var/www/html/glpi/vendor/symfony/dom-crawler)
twig/twig in (/var/www/html/glpi/vendor/twig/twig/src)
twig/string-extra in (/var/www/html/glpi/vendor/twig/string-extra)
symfony/polyfill-ctype not found
symfony/polyfill-iconv not found
symfony/polyfill-mbstring not found
symfony/polyfill-php80 not found
symfony/polyfill-php81 not found
symfony/polyfill-php82 in (/var/www/html/glpi/vendor/symfony/polyfill-php82)
phpCas version 1.3.8 in (/usr/share/php/CAS/source)

LDAP directories
 
I was asked to remove that by my superior because it was not anonymised.
SQL replicas
 
Not active

Notifications
 
Way of sending emails: PHP

Plugins list
 
    advanceddashboard    Name: advanceddashboard              Version: 1.4.3      State: Enabled                                 
        Install Method: Marketplace
    news                 Name: Alertes                        Version: 1.10.5     State: Enabled                                 
        Install Method: Marketplace
    anonymize            Name: Anonymize                      Version: 2.7.0      State: Enabled                                 
        Install Method: Marketplace
    approvalbymail       Name: Approval by mail               Version: 2.1.1      State: Enabled                                 
        Install Method: Marketplace
    branding             Name: Branding                       Version: 1.3.2      State: Enabled                                 
        Install Method: Marketplace
    fields               Name: Champs supplémentaires         Version: 1.20.0     State: Enabled                                 
        Install Method: Marketplace
    accounts             Name: Comptes                        Version: 3.0.2      State: Enabled                                 
        Install Method: Marketplace
    printercounters      Name: Compteurs Imprimantes          Version: 2.0.0      State: Enabled                                 
        Install Method: Marketplace
    uninstall            Name: Cycle de vie des matériels (un Version: 2.8.1      State: Enabled                                 
        Install Method: Marketplace
    datainjection        Name: Data Injection                 Version: 2.12.1     State: Enabled                                 
        Install Method: Marketplace
    formcreator          Name: Form Creator                   Version: 2.13.4     State: Enabled                                 
        Install Method: Marketplace
    order                Name: Gestion des commandes          Version: 2.10.1     State: Enabled                                 
        Install Method: Marketplace
    glpiinventory        Name: GLPI Inventory                 Version: 1.1.0      State: Enabled                                 
        Install Method: Marketplace
    holiday              Name: Holidays                       Version: 1.2.0      State: Enabled                                 
        Install Method: Marketplace
    manufacturersimports Name: Imports fabricants             Version: 3.0.5      State: Enabled                                 
        Install Method: Marketplace
    pdf                  Name: Impression pdf                 Version: 3.0.0      State: Enabled                                 
        Install Method: Marketplace
    oauthimap            Name: Oauth IMAP                     Version: 1.4.1      State: Enabled                                 
        Install Method: Marketplace
    oauthsso             Name: oauthsso                       Version: 1.9.2      State: Enabled                                 
        Install Method: Marketplace
    collaborativetools   Name: Outils collaboratifs           Version: 1.2.2      State: Enabled                                 
        Install Method: Marketplace
    mreporting           Name: Plus de rapports               Version: 1.8.2      State: Enabled                                 
        Install Method: Marketplace
    localeoverride       Name: Renommer les chaînes de GLPI   Version: 1.1.5      State: Enabled                                 
        Install Method: Marketplace
    resources            Name: Ressources humaines            Version: 3.0.4      State: Enabled                                 
        Install Method: Marketplace
    splitcat             Name: Split categories               Version: 1.5.2      State: Enabled                                 
        Install Method: Marketplace
    vip                  Name: VIP                            Version: 1.8.2      State: Enabled                                 
        Install Method: Marketplace

Anything else?

server = https://helpdesk.media-participations.com/marketplace/glpiinventory/ in the agent registry.

If I set debug=2 in the agent, I can see the JSON file generated inside the "$env:ProgramFiles/GLPI-Agent/logs/glpi-agent.log".

It seems it is having a problem either sending it to the server or inserting it into the database.

stonebuzz commented 1 year ago

Hi @sebma can you retry GLPI nighlty build ?

https://nightly.glpi-project.org/glpi/

Your issue should be fixed.

Best regards

sebma commented 1 year ago

@stonebuzz Thank you. Before we do that, do you have the PR that fixes this bug ?

sebma commented 1 year ago

Hereby attached are the php-errors.log and the sql-errors.log.

stonebuzz commented 1 year ago

I found this from your log

  SQL: INSERT INTO `glpi_agents` (`deviceid`, `name`, `last_contact`, `useragent`, `agenttypes_id`, `itemtype`, `version`, `remote_addr`, `items_id`, `threads_networkdiscovery`, `threads_networkinventory`, `timeout_networkdiscovery`, `timeout_networkinventory`) VALUES ('A.FQDN.lan-2022-12-29-09-49-15', 'A.FQDN.lan-2022-12-29-09-49-15', '2023-02-08 12:01:02', 'GLPI-Agent_v1.4', NULL, 'Computer', '1.4', '10.10.10.6', '0', '0', '0', '0', '0')
  Error: Column 'agenttypes_id' cannot be null

Can you post here result of this SQL query

select * from glpi_agenttypes;

Best regards

stonebuzz commented 1 year ago

This warning is related to splitcat plugin

[2023-02-08 16:20:43] glpiphplog.WARNING:   *** PHP Warning (2): Undefined array key "id" in /var/www/html/glpi/marketplace/splitcat/inc/itilcategory.class.php at line 280
  Backtrace :
  marketplace/splitcat/inc/itilcategory.class.php:70 PluginSplitcatITILCategory::getItilCatSelect()
  marketplace/splitcat/ajax/splitcat.php:52          PluginSplitcatITILCategory::ajax()
stonebuzz commented 1 year ago

It seems you have a GLPI Network subscription, please contact us directly

sebma commented 6 months ago

@stonebuzz Hi, I'm in trouble with my superior because I forgot to anonymise data before posting this issue.

I just removed some data today, can you also anonymise the FQDN contained in the INSERT INTO SQL line in your answer posted at https://github.com/glpi-project/glpi/issues/14039#issuecomment-1423047310 ?

Thank you for your understanding.

stonebuzz commented 6 months ago

done

sebma commented 6 months ago

@stonebuzz Thanks a lot.