Skip to content

Breaking change in PR #21: Added JamfProperty.ID field with wrong type causes JSON unmarshaling failure #23

Description

@azainal-gemini

Summary

PR #21 introduced a breaking change by adding an ID int field to the JamfProperty struct, but Jamf's API returns site IDs as strings, causing JSON unmarshaling failures.

Error Details

Error unmarshalling cache data: json: cannot unmarshal string into Go struct field Site.results.general.site.JamfProperty.id of type int

This error occurs during:

  • ListAllComputers() operations
  • Computer count operations
  • Both cached and non-cached API calls

Affected Versions

  • Working version: v0.0.0-20250529045826-8981c238fe8d (May 29, 2025)
  • Breaking version: v0.0.0-20250811144524-da222d829c5d (August 11, 2025)

Exact Breaking Change Location

File: pkg/jamf/entities.goLines: 41-42Struct: JamfProperty

PR #21 added a new ID field typed as int:

// BREAKING CHANGE - Added in PR #21

  type JamfProperty struct {
      ID   int    `json:"id,omitempty" xml:"id,omitempty"`     // ID of the object.
      Name string `json:"name,omitempty" xml:"name,omitempty"` // Name of the object.
  }

Root Cause: Jamf's API returns site IDs as strings ("123"), but this struct expects integers (123).

Example of actual Jamf API response:

  {
    "results": [
      {
        "general": {
          "site": {
            "id": "123",    // ← String from Jamf API
            "name": "Main Site"
          }
        }
      }
    ]
  }

Impact

  • Complete failure of Jamf API operations in production systems
  • CI/CD pipelines broken when go mod tidy pulls latest version
  • Error persists even with caching disabled
  • Cannot be worked around in consuming applications (error occurs during JSON unmarshaling inside rego library)

Reproduction Steps

  1. Use rego library version v0.0.0-20250811144524-da222d829c5d
  2. Call jamfClient.Devices().ListAllComputers() or any method returning computer data with site information
  3. Observe JSON unmarshaling failure

Expected Behavior

The library should handle Jamf's actual API response format correctly, as it did in the previous working version.

Proposed Fix

Change the field type to match Jamf's API format:

  type JamfProperty struct {
      ID   string `json:"id,omitempty" xml:"id,omitempty"`     // ID of the object (matches Jamf API string format)
      Name string `json:"name,omitempty" xml:"name,omitempty"` // Name of the object.
  }

Alternative approaches:

  • Use json.Number for flexible type handling
  • Use interface{} to accept both strings and integers

Temporary Workaround

Pin to the working version in go.mod:

  require (
      github.com/gemini-oss/rego v0.0.0-20250529045826-8981c238fe8d
  )

References

Priority: High - This affects any production system using automated dependency updates and Jamf API operations.

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