Skip to content

LogsResponse in AuditClient returns "ok: false" when request was a success  #1373

@Dunkhell

Description

@Dunkhell

I'm using latest version of the SDK.

When requesting audit logs with any parameters the response is alwyas ok: false. The response doesn't provide warning or error message but does contain requested entries for the audit log.

The Slack SDK version

<dependency>
    <groupId>com.slack.api</groupId>
    <artifactId>slack-api-client</artifactId>
    <version>1.42.1</version>
</dependency>

Java Runtime version

openjdk version "17.0.8"

Steps to reproduce:

  1. Create AuditClient
  2. Create logs request with any parameters
  3. Check if "response.isOk()"

code ran:

public class AuditLogSlackService {

    private final Slack slack; // autowired using spring

    public List<LogsResponse.Entry> getLogs(String action, Integer latest, Integer oldest, String actor) {
        AuditClient auditClient = slack.audit("user-token");

        LogsRequest request = LogsRequest.builder()
                .token("user-token")
                .action(action)
                .build();

        Optional.ofNullable(latest).ifPresent(request::setLatest);
        Optional.ofNullable(oldest).ifPresent(request::setOldest);
        Optional.ofNullable(actor).ifPresent(request::setActor);

        RetryTemplate retry = RetryServiceUtil.getRetryTemplate(); // retry can be omitted for this example
        return retry.execute(arg0 -> {
            List<LogsResponse.Entry> result = new ArrayList<>();

            do {
                try {
                    LogsResponse response = auditClient.getLogs(request);
                    if (response.isOk()) {
                        result.addAll(response.getEntries());
                        request.setCursor(ofNullable(response.getResponseMetadata()).map(ResponseMetadata::getNextCursor).orElse(""));
                    } else {
                        throw new RuntimeException(response.getError());
                    }
                } catch (Exception e) {
                    log.info("{} Failed with {}", "LogsRequest", e.toString());
                    throw new RuntimeException(e.getMessage());
                }
                log.info("Retry finished for " + "LogsRequest");
            } while (!request.getCursor().isEmpty());
            return result;
        });
    }
}

Code contains custom exceptions and logging, which can be ignored since they do not result in the error

Expected result:

Response is ok: true and contains entries of the requested audit logs.

Actual result:

Response is ok: false and contains entries of the requested audit logs.

LogsResponse(rawBody=null, ok=false, warning=null, error=null, needed=null, provided=null, responseMetadata=ResponseMetadata(nextCursor=, messages=null, warnings=null), entries=[LogsResponse.Entry(all_entries_here....)])

Metadata

Metadata

Assignees

Labels

bugM-T: confirmed bug report. Issues are confirmed when the reproduction steps are documentedproject:slack-api-clientproject:slack-api-client

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions