Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Undefined array key on Asset import #18917

Draft
wants to merge 1 commit into
base: 10.0/bugfixes
Choose a base branch
from

Conversation

eduardomozart
Copy link
Contributor

@eduardomozart eduardomozart commented Feb 4, 2025

Checklist before requesting a review

Please delete options that are not relevant.

  • I have read the CONTRIBUTING document.
  • I have performed a self-review of my code.
  • I have added tests that prove my fix is effective or that my feature works.
  • This change requires a documentation update.

Description

  • It fixes # (issue number, if applicable)
  • Here is a brief description of what this PR does

Screenshots (if appropriate):

The error "Undefined array key" is thrown on GLPI-Agent 1.12 when importing Inventory from a Windows machine when modifying the "Computer update (by serial + uuid)" from "Link if possible" (default) to "Link if possible, otherwise imports declined".

image

I did a error_log(print_r($datarules, true)) before the if call and it returns the following:

(
    [rules_id] => 247
    [_ruleid] => 247
)

This ID reflects the rule Computer update (by serial + uuid) which refers to the Rule where it stopped and the asset hasn't been imported. Notice that there's no action key on the array. This PR do the action validation only if it's set.

The machine doesn't exist on the glpi_computers DB (it existed before but has been deleted). The inventory file of this machine is in attachment.

computer_0_46.json
rules.xml.txt

@stonebuzz
Copy link
Contributor

Hi @eduardomozart,

I successfully completed the first import without any issues or Undefined array key. I then adjusted the rule accordingly.

The second import also ran without any errors.

Could you provide me with an export of your computer rules?

image

@trasher
Copy link
Contributor

trasher commented Feb 5, 2025

A test case to reproduce is needed

@eduardomozart
Copy link
Contributor Author

eduardomozart commented Feb 5, 2025

Hello @trasher and @stonebuzz, I've updated the inventory file and exported the rules XML file as requested and was able to reproduce the issue by importing the inventory file manually. Please make sure to attempt to import the file with the GLPI Debug mode enabled and PHP display_errors directive set to 'On'. It states "File has been successfully imported" but I think that for "Import denied (no log)" it should also return as refused because it can confuse the user, as in fact the Computer asset hasn't been imported.

image

@eduardomozart eduardomozart marked this pull request as draft February 5, 2025 10:37
@stonebuzz
Copy link
Contributor

Always nothing on my side

image

image

@stonebuzz
Copy link
Contributor

Could you try again by resetting your rules?

@eduardomozart
Copy link
Contributor Author

eduardomozart commented Feb 5, 2025

If I reset the rules it should work as expected since it happens only when the rule Computer update (by serial + uuid) is set to Link if possible, otherwise import denied. Did the asset has been created for you? I deleted it without keeping associated devices, changed the rule and it hasn't been imported for me at all. Please also make sure that your Administration > Inventory > Virtualization settings is as below:
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants