• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #7017

15 May 2026 10:43AM UTC coverage: 12.513% (-0.007%) from 12.52%
#7017

Pull #1845

github

web-flow
Merge 34e8ed42f into 2508710cc
Pull Request #1845: feat(boxsdkgen): Sanitize request body (box/box-codegen#948)

0 of 40 new or added lines in 5 files covered. (0.0%)

4 existing lines in 2 files now uncovered.

8374 of 66920 relevant lines covered (12.51%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/box/sdkgen/box/errors/BoxAPIError.java
1
package com.box.sdkgen.box.errors;
2

3
import com.box.sdkgen.internal.logging.DataSanitizer;
4
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
5
import com.fasterxml.jackson.databind.JsonNode;
6
import java.time.LocalDateTime;
7
import java.util.Optional;
8
import okhttp3.Request;
9

10
public class BoxAPIError extends BoxSDKError {
11

12
  public final RequestInfo requestInfo;
13

14
  public final ResponseInfo responseInfo;
15

16
  private final DataSanitizer dataSanitizer;
17

18
  public BoxAPIError(String message, RequestInfo requestInfo, ResponseInfo responseInfo) {
19
    super(message);
×
20
    this.requestInfo = requestInfo;
×
21
    this.responseInfo = responseInfo;
×
22
    this.dataSanitizer = new DataSanitizer();
×
23
  }
×
24

25
  public static BoxAPIError fromAPICall(
26
      Request request,
27
      FetchResponse fetchResponse,
28
      String rawResponseBody,
29
      DataSanitizer dataSanitizer) {
NEW
30
    return fromAPICall(request, fetchResponse, rawResponseBody, dataSanitizer, null);
×
31
  }
32

33
  public static BoxAPIError fromAPICall(
34
      Request request,
35
      FetchResponse fetchResponse,
36
      String rawResponseBody,
37
      DataSanitizer dataSanitizer,
38
      String contentType) {
NEW
39
    RequestInfo requestInfo = RequestInfo.fromRequest(request, contentType);
×
UNCOV
40
    ResponseInfo responseInfo = ResponseInfo.fromResponse(fetchResponse, rawResponseBody);
×
41

42
    String requestId =
×
43
        Optional.ofNullable(responseInfo.getBody())
×
44
            .map(body -> body.get("request_id"))
×
45
            .map(JsonNode::asText)
×
46
            .orElse("");
×
47

48
    return new Builder(
×
49
            String.format("Status %d; Request ID: %s", responseInfo.getStatusCode(), requestId),
×
50
            requestInfo,
51
            responseInfo)
52
        .timestamp(LocalDateTime.now().toString())
×
53
        .dataSanitizer(dataSanitizer)
×
54
        .build();
×
55
  }
56

57
  protected BoxAPIError(Builder builder) {
58
    super(builder);
×
59
    this.requestInfo = builder.requestInfo;
×
60
    this.responseInfo = builder.responseInfo;
×
61
    this.dataSanitizer = builder.dataSanitizer;
×
62
  }
×
63

64
  public RequestInfo getRequestInfo() {
65
    return requestInfo;
×
66
  }
67

68
  public ResponseInfo getResponseInfo() {
69
    return responseInfo;
×
70
  }
71

72
  public static class Builder extends BoxSDKError.Builder {
73

74
    protected final RequestInfo requestInfo;
75

76
    protected final ResponseInfo responseInfo;
77

78
    protected DataSanitizer dataSanitizer;
79

80
    public Builder(String message, RequestInfo requestInfo, ResponseInfo responseInfo) {
81
      super(message);
×
82
      this.requestInfo = requestInfo;
×
83
      this.responseInfo = responseInfo;
×
84
      this.dataSanitizer = new DataSanitizer();
×
85
    }
×
86

87
    @Override
88
    public Builder timestamp(String timestamp) {
89
      this.timestamp = timestamp;
×
90
      return this;
×
91
    }
92

93
    @Override
94
    public Builder error(Exception error) {
95
      this.error = error;
×
96
      return this;
×
97
    }
98

99
    @Override
100
    public Builder name(String name) {
101
      this.name = name;
×
102
      return this;
×
103
    }
104

105
    public Builder dataSanitizer(DataSanitizer dataSanitizer) {
106
      this.dataSanitizer = dataSanitizer;
×
107
      return this;
×
108
    }
109

110
    public BoxAPIError build() {
111
      return new BoxAPIError(this);
×
112
    }
113
  }
114

115
  @Override
116
  public String toString() {
117
    return String.join(
×
118
        "",
119
        super.toString(),
×
120
        String.format("\nRequest: %s", requestInfo.print(dataSanitizer)),
×
121
        String.format("\nResponse: %s", responseInfo.print(dataSanitizer)));
×
122
  }
123
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc