Skip to content

[Bug]: Sync adapters: a false boolean extra fails checkbox custom-field validation #19725

Description

@bjhinkle

Snipe-IT Version

develop d33c59c (our test instance); these code paths are unchanged on current develop (7fe44cd)

PHP Version

8.3.6

Composer Version

2.7.1

MySQL/MariaDB version

MariaDB 10.11.14

How did you install Snipe-IT?

Git install

Is this a fresh install or an upgrade?

Fresh install

What happened?

Boolean extras (declared with 'type' => 'boolean') are written as '1' or '0' by stringifyExtra(). For a checkbox custom field whose one option is 1, '1' saves, but '0' fails the checkboxes rule ("contains invalid options"). So a device whose value is false can't be saved at all. #19628 describes mapping boolean extras such as Kandji's MDM Enabled to a checkbox custom field, and that path fails for every false value.

We hit it on a develop test instance while building the Sophos Central adapter from #19696. Its tamper-protection flag is a boolean extra mapped to a checkbox field. The 2 endpoints with tamper protection off got none of their mapped values, while the other 91 were fine. The run still reported 0 errors; I'm filing that part separately.

Steps to reproduce:

  1. Create a checkbox custom field with one option, 1, and add it to the model's fieldset.
  2. Map any boolean extra to it.
  3. Sync a device whose value for that extra is false.

The asset fails validation and none of its mapped values are saved. Setting the same field to an empty string saves fine.

Expected: false leaves the checkbox unchecked. One way would be for stringifyExtra() to return an empty string for a false boolean.

Drafted with help from an AI assistant. The results are from our own test instance.

What browsers are you seeing the problem on?

No response

Can you reproduce this on the public demo?

N/A

Do you have full multiple company support enabled?

No

If you have full multiple company support enabled, do you have location scoping to company enabled?

I do not have full multiple company support enabled

Application log output

Nothing is logged. The asset's validation message ($asset->getErrors()):
snipeit sophos tamper protection 5 contains invalid options.

Browser console output

No response

Common Issues

  • I have searched this repo for existing issues related to my issue (including closed issues)
  • My APP_URL is set correctly in my .env file (including http or https and no trailing slash)
  • I have searched the official Snipe-IT documentation and have checked the Common Issues documentation (where applicable)
  • I have run database migrations (where applicable).
  • I have attached screenshots and/or videos of the issue (where applicable)

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

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

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