Skip to content

fix: parse details.action in audit logs as a string or an object - #1703

Merged
zimeg merged 8 commits into
mainfrom
details-action
Nov 18, 2026
Merged

zimeg merged 8 commits into
mainfrom
details-action

Conversation

@zimeg

@zimeg zimeg commented Nov 17, 2026

Copy link
Copy Markdown
Member

Summary

This pull request parses details.action in audit logs as either a string or an object.

  • Slack sends details.action as a string for some actions, such as "update" for usergroup_updated, and as an object with resolution and notify for others, such as app_allowlist_rule_created. With the current String type, any getLogs page that includes the object form fails to parse with JsonSyntaxException: Expected a string but was BEGIN_OBJECT.
  • LogsResponse.Details.action is now a LogsResponse.DetailsAction that holds either form. A new GsonAuditLogsDetailsActionFactory, registered in GsonFactory, reads both, the same way succeededUsers and failedUsers read UserIDs.
  • With failOnUnknownProperties on, unknown keys in the object form raise an error.
  • AAARuleActionNotify gains values.

This is a breaking change for code that reads the field as a string. To migrate, replace details.getAction() with details.getAction().getStringValue(), or read getResolution() and getNotify() for the object form.

This is the base of a stack:

  1. this pull request
  2. feat: add webapi response changes as of 2026-11-17 #1636 webapi response changes

Testing

With an org admin token that has auditlogs:read:

  • slack.audit(token).getLogs(r -> r.action("app_allowlist_rule_created")) parses, and getDetails().getAction().getResolution() is set.
  • slack.audit(token).getLogs(r -> r.action("usergroup_updated")) parses, and getDetails().getAction().getStringValue() is "update".

Category

  • bolt (Bolt for Java)
  • bolt-{sub modules} (Bolt for Java - optional modules)
  • slack-api-client (Slack API Clients)
  • slack-api-model (Slack API Data Models)
  • slack-api-*-kotlin-extension (Kotlin Extensions for Slack API Clients)
  • slack-app-backend (The primitive layer of Bolt for Java)

Requirements

🤖 Generated with Claude Code

zimeg and others added 2 commits November 16, 2026 18:42
❤️
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@zimeg zimeg added this to the 1.55.1 milestone Nov 17, 2026
@zimeg zimeg added bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:slack-api-client project:slack-api-client semver:minor labels Nov 17, 2026
@zimeg zimeg self-assigned this Nov 17, 2026
@codecov

codecov Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 74.54545% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.84%. Comparing base (b2d12b0) to head (0395023).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
...i/util/json/GsonAuditLogsDetailsActionFactory.java 74.07% 8 Missing and 6 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #1703      +/-   ##
============================================
- Coverage     73.95%   73.84%   -0.12%     
- Complexity     4771     4783      +12     
============================================
  Files           488      489       +1     
  Lines         14865    14920      +55     
  Branches       1543     1559      +16     
============================================
+ Hits          10993    11017      +24     
- Misses         2959     2978      +19     
- Partials        913      925      +12     
Flag Coverage Δ
jdk-14 73.84% <74.54%> (-0.12%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@zimeg zimeg left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

🗣️ a comment as we reduce these

…ains

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg
zimeg marked this pull request as ready for review November 18, 2026 18:00
@zimeg
zimeg requested a review from a team as a code owner November 18, 2026 18:00

@cchensh cchensh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Non-blocking nits:

  1. An explicit JSON null for details.action falls into the final else: it throws in strict mode, and in lenient mode it returns an empty DetailsAction instead of null. An isJsonNull() early return would fix it (the DetailsChangedValue factory has the same gap).
  2. json-logs/samples/audit/v1/logs.json still only has the string form of details.action. Adding an object-form entry would cover it in the sample-based tests too.
  3. Since getAction() changes from String, please call it out in the release notes with the migration line from the description.

@mwbrooks mwbrooks left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

✅ Thanks @zimeg! Reading details.action as either a string or an object means getLogs stops failing on app allowlist events.

Co-authored-by: Cheng Chen <35309699+cchensh@users.noreply.github.com>

Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
@zimeg

zimeg commented Nov 18, 2026 •

Copy link
Copy Markdown
Member Author

@cchensh Notes on each of these:

  1. 🧪 note: An explicit null doesn't reach the factory, since registerTypeAdapter wraps it null-safe and Gson returns null before calling deserialize. I checked {"details":{"action":null}} on this branch and getAction() is null in both strict and lenient modes, and the same wrapping covers DetailsChangedValue.
  2. 🧹 Added an object-form details.action entry to logs.json in d701b22. It comes from regenerateLogsSampleJSONData, so the next audit run keeps it, and the mock getLogs tests now parse both forms.
  3. 📝 Noted for the release notes, with the migration line from the description.

@zimeg

zimeg commented Nov 18, 2026

Copy link
Copy Markdown
Member Author

🌟 Thanks for the kind reviews @cchensh and @mwbrooks!

@zimeg
zimeg merged commit ba1aa12 into main Nov 18, 2026
7 checks passed
@zimeg
zimeg deleted the details-action branch November 18, 2026 21:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug M-T: confirmed bug report. Issues are confirmed when the reproduction steps are documented project:slack-api-client project:slack-api-client semver:minor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants