Skip to content

Conversation

@ShourieG
Copy link
Contributor

@ShourieG ShourieG commented Mar 27, 2025

Type of change

  • Bug

Proposed commit message

WHAT: Fixed empty string issue for date query param in filter for Jamf Pro inventory data stream.

WHY: Recently there was a commit changing how the filter works detailed here. The issue is that this change does not take into account the fact that due to the previously existing cursor logic, there could be scenarios where the cursor.last_report_date is an empty string.

Sending the date in the filter as an empty string causes the API to respond with a status_code: 400 leading to failures. The fix in this PR tries to address this specific issue along with some minor cleanup.

Commit Message: The current cursor handling assumes that state.cursor.last_report_date is either absent or a valid cursor. However, previously stored cursor values may include an empty string for this value to indicate an absence. The outcome of this is that an invalid filter parameter was being sent in those cases. This changes the logic to correctly handle cursors that have used an empty string as an absence marker.

NOTE

Some minor cleanup and additions are included since they are all + changes. Some are just elastic-package format behaviour.

Checklist

  • I have reviewed tips for building integrations and this pull request is aligned with them.
  • I have verified that all data streams collect metrics or logs.
  • I have added an entry to my package's changelog.yml file.
  • I have verified that Kibana version constraints are current according to guidelines.
  • I have verified that any added dashboard complies with Kibana's Dashboard good practices

Author's Checklist

  • [ ]

How to test this PR locally

Related issues

Screenshots

@ShourieG ShourieG requested a review from a team as a code owner March 27, 2025 07:38
@ShourieG ShourieG self-assigned this Mar 27, 2025
@ShourieG ShourieG added the Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations] label Mar 27, 2025
@elasticmachine
Copy link

Pinging @elastic/security-service-integrations (Team:Security-Service Integrations)

@ShourieG ShourieG added Integration:jamf_pro Jamf Pro bugfix Pull request that fixes a bug issue labels Mar 27, 2025
"capableUsers": ["user.mcuserface@company.com"]
"capableUsers": [
"user.mcuserface@company.com"
]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cause by elastic-package, but its a + change so I let it stay.


keep_null: true
redact:
fields: ~
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added recommended redact field since it's a + change.

*NOTE* Enabling many sections may impact query processing.
It is recommended to only enable sections of interest.
The General section is always included.
description: "Settings for inventory requests. \n*NOTE* Enabling many sections may impact query processing.\nIt is recommended to only enable sections of interest.\nThe General section is always included.\n"
Copy link
Contributor Author

@ShourieG ShourieG Mar 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

caused by elastic-package format, but is good to have

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this improves things.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes agree but since it aligns with the format expected by elastic-package, I think it's ok to keep it in.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it reflects a bug in the yaml implementation and it makes the code harder to read, but I won't push.

@ShourieG ShourieG changed the title [Jamf_Pro] - Fix empty string issue for date query param in filter for Jamf Pro in inventory data stream [Jamf_Pro] - Fix empty string issue for date query param in filter for Jamf Pro inventory data stream Mar 27, 2025
@elastic-vault-github-plugin-prod

🚀 Benchmarks report

To see the full report comment with /test benchmark fullreport

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest the following for the commit message:

The current cursor handling assumes that state.cursor.last_report_date is
either absent or a valid cursor. However, previously stored cursor values may
include an empty string for this value to indicate an absence. The outcome of
this is that an invalid filter parameter was being sent in those cases. This
changes the logic to correctly handle cursors that have used an empty string
as an absence marker.

Note that commit messages do not render markdown.

Comment on lines 41 to 44
?"filter": (has(state.?cursor.last_report_date) && state.cursor.last_report_date.orValue("") != "") ?
optional.of(["general.reportDate>=\"" + state.cursor.last_report_date + "\""])
:
optional.none(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
?"filter": (has(state.?cursor.last_report_date) && state.cursor.last_report_date.orValue("") != "") ?
optional.of(["general.reportDate>=\"" + state.cursor.last_report_date + "\""])
:
optional.none(),
?"filter": state.?cursor.last_report_date.orValue("") != "" ?
optional.of(["general.reportDate>=\"" + state.cursor.last_report_date + "\""])
:
optional.none(),

state.cursor.last_report_date.orValue("") is not valid since state.cursor.last_report_date is not an optional type.

*NOTE* Enabling many sections may impact query processing.
It is recommended to only enable sections of interest.
The General section is always included.
description: "Settings for inventory requests. \n*NOTE* Enabling many sections may impact query processing.\nIt is recommended to only enable sections of interest.\nThe General section is always included.\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure this improves things.

@ShourieG
Copy link
Contributor Author

ShourieG commented Mar 27, 2025

@efd6, addressed all suggested changes.

@ShourieG ShourieG requested a review from efd6 March 27, 2025 08:52
@elastic-sonarqube
Copy link

@elasticmachine
Copy link

💚 Build Succeeded

History

cc @ShourieG

Copy link
Contributor

@efd6 efd6 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks.

Please make sure the line wraps are sane in the final commit message.

*NOTE* Enabling many sections may impact query processing.
It is recommended to only enable sections of interest.
The General section is always included.
description: "Settings for inventory requests. \n*NOTE* Enabling many sections may impact query processing.\nIt is recommended to only enable sections of interest.\nThe General section is always included.\n"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it reflects a bug in the yaml implementation and it makes the code harder to read, but I won't push.

@ShourieG ShourieG merged commit fa56b59 into elastic:main Mar 27, 2025
7 checks passed
@ShourieG ShourieG deleted the jamf_pro/filter_bugfix_5779 branch March 27, 2025 09:53
@elastic-vault-github-plugin-prod

Package jamf_pro - 0.5.1 containing this change is available at https://epr.elastic.co/package/jamf_pro/0.5.1/

flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…r Jamf Pro inventory data stream (#13329)

The current cursor handling assumes that state.cursor.last_report_date is either absent or a valid cursor. However, previously stored cursor values may include an empty string for this value to indicate an absence. The outcome of this is that an invalid filter parameter was being sent in those cases. This changes the logic to correctly handle cursors that have used an empty string as an absence marker.
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…r Jamf Pro inventory data stream (#13329)

The current cursor handling assumes that state.cursor.last_report_date is either absent or a valid cursor. However, previously stored cursor values may include an empty string for this value to indicate an absence. The outcome of this is that an invalid filter parameter was being sent in those cases. This changes the logic to correctly handle cursors that have used an empty string as an absence marker.
flexitrev pushed a commit that referenced this pull request Mar 28, 2025
…r Jamf Pro inventory data stream (#13329)

The current cursor handling assumes that state.cursor.last_report_date is either absent or a valid cursor. However, previously stored cursor values may include an empty string for this value to indicate an absence. The outcome of this is that an invalid filter parameter was being sent in those cases. This changes the logic to correctly handle cursors that have used an empty string as an absence marker.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Pull request that fixes a bug issue Integration:jamf_pro Jamf Pro Team:Security-Service Integrations Security Service Integrations team [elastic/security-service-integrations]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants