Skip to content

[Bug]: Sync adapters: a failed asset save during sync is counted as success #19726

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?

In SyncsHostFromRecord::syncFromRecord(), the asset is saved with $asset->saveOrFail(), and the return value isn't checked. With the model's validation, a failed save makes saveOrFail() return false instead of throwing. So the record's whole update is dropped, and snipeit:pull-inventory still counts it as synced, with nothing in the sync log.

We saw it on a develop test instance, with a boolean extra mapped to a checkbox field (reported separately). 2 of 93 devices kept none of their mapped values, and the run reported "93 record(s) processed, 0 error(s)". Calling saveOrFail() directly on one of those assets returned false with the validation message and no exception. Any mapped value that fails the asset's validation would take the same path.

Expected: a failed save counts as an error for that record, with the validation messages in the sync log. createShellAsset() already does this for new assets: it checks the result of save() and throws with getErrors().

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

Related: #19725

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

[2026-09-28 15:32:10] production.INFO: sophosdev sync starting (CLI)
[2026-09-28 15:32:12] production.INFO: sophosdev sync complete: 93 record(s) processed, 0 error(s), elapsed 1.8s

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