-
Notifications
You must be signed in to change notification settings - Fork 33
Add types for all the Databricks error detail types. #497
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b76245d
Deserialize error details
renaudhartert-db b1d08c9
fmt
renaudhartert-db b05e7ed
Better formatting
renaudhartert-db ebc0a13
Update setters
renaudhartert-db 187ac13
Fix test
renaudhartert-db 2ce2627
fmt
renaudhartert-db 4f9fadf
No null collections
renaudhartert-db 0a16bf2
Handle PR comments
renaudhartert-db 1aa9888
Add comments
renaudhartert-db 16a8b1d
Add comments
renaudhartert-db d016a93
Remove unnecessary checks
renaudhartert-db 2d0edf7
Default to empty list
renaudhartert-db e2dcdad
Default to empty list
renaudhartert-db 730b479
fmt
renaudhartert-db 2f963ec
Merge branch 'main' into renaud-hartert_data/error1
renaudhartert-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
192 changes: 192 additions & 0 deletions
192
databricks-sdk-java/src/main/java/com/databricks/sdk/core/error/details/BadRequest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,192 @@ | ||
| package com.databricks.sdk.core.error.details; | ||
|
|
||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.fasterxml.jackson.databind.annotation.JsonDeserialize; | ||
| import com.google.auto.value.AutoValue; | ||
| import java.util.Collections; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * BadRequest describes violations in a client request. This error type focuses on the syntactic | ||
| * aspects of the request. | ||
| * | ||
| * <p>BadRequest errors occur when the request format, structure, or content does not meet the | ||
| * service's requirements. This is different from business logic errors or system failures - it | ||
| * specifically indicates that the client sent a malformed or invalid request. | ||
| * | ||
| * <p>Examples of bad request violations might include: | ||
| * | ||
| * <ul> | ||
| * <li>Missing required fields | ||
| * <li>Invalid field values (wrong type, format, or range) | ||
| * <li>Malformed JSON or XML | ||
| * <li>Unsupported field combinations | ||
| * <li>Invalid enum values | ||
| * <li>Field length or size violations | ||
| * </ul> | ||
| * | ||
| * <p>This information helps clients: | ||
| * | ||
| * <ul> | ||
| * <li>Identify what's wrong with their request | ||
| * <li>Fix the request format before retrying | ||
| * <li>Understand the service's input requirements | ||
| * <li>Implement proper input validation | ||
| * </ul> | ||
| */ | ||
| @AutoValue | ||
| @JsonDeserialize(builder = AutoValue_BadRequest.Builder.class) | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public abstract class BadRequest { | ||
|
|
||
| /** | ||
| * Describes all field violations in the request. | ||
| * | ||
| * <p>This list contains details about each specific field or aspect of the request that violated | ||
| * the service's requirements. Multiple violations can occur if the request has multiple problems. | ||
| * | ||
| * @return the list of field violations | ||
| */ | ||
| @JsonProperty("field_violations") | ||
| public abstract List<BadRequestFieldViolation> fieldViolations(); | ||
|
|
||
| /** | ||
| * Creates a new builder for constructing BadRequest instances. | ||
| * | ||
| * @return a new builder instance | ||
| */ | ||
| public static Builder builder() { | ||
| return new AutoValue_BadRequest.Builder(); | ||
| } | ||
|
|
||
| /** Builder for constructing BadRequest instances. */ | ||
| @AutoValue.Builder | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public abstract static class Builder { | ||
|
|
||
| /** | ||
| * Sets the field violations. | ||
| * | ||
| * @param fieldViolations the list of field violations | ||
| * @return this builder for method chaining | ||
| */ | ||
| @JsonProperty("field_violations") | ||
| public abstract Builder setFieldViolations(List<BadRequestFieldViolation> fieldViolations); | ||
|
|
||
| /** | ||
| * Builds the BadRequest instance. | ||
| * | ||
| * @return a new BadRequest instance | ||
| */ | ||
| public BadRequest build() { | ||
| if (fieldViolations() == null) { | ||
| setFieldViolations(Collections.emptyList()); | ||
| } | ||
| return autoBuild(); | ||
| } | ||
|
|
||
| abstract List<BadRequestFieldViolation> fieldViolations(); | ||
|
|
||
| abstract BadRequest autoBuild(); | ||
| } | ||
|
|
||
| /** | ||
| * BadRequestFieldViolation describes a specific field violation in a request. | ||
| * | ||
| * <p>Each violation provides details about what specific field or aspect of the request was | ||
| * invalid and how the client can fix it. | ||
| */ | ||
| @AutoValue | ||
| @JsonDeserialize(builder = AutoValue_BadRequest_BadRequestFieldViolation.Builder.class) | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public abstract static class BadRequestFieldViolation { | ||
|
|
||
| /** | ||
| * A path leading to a field in the request body. | ||
| * | ||
| * <p>This field identifies the specific location of the violation within the request structure. | ||
| * The path format depends on the request format but typically follows a hierarchical structure. | ||
| * | ||
| * <p>Examples of field paths: | ||
| * | ||
| * <ul> | ||
| * <li>"name" - top-level field | ||
| * <li>"user.email" - nested field | ||
| * <li>"items[0].id" - array element field | ||
| * <li>"metadata.api_key" - deeply nested field | ||
| * <li>"settings.notifications.enabled" - multi-level nested field | ||
| * </ul> | ||
| * | ||
| * <p>This path helps clients quickly locate and fix the problematic field in their request. | ||
| * | ||
| * @return the path to the violating field | ||
| */ | ||
| @JsonProperty("field") | ||
| public abstract String field(); | ||
|
|
||
| /** | ||
| * A description of why the request element is bad. | ||
| * | ||
| * <p>This field provides a human-readable explanation of what's wrong with the field and how to | ||
| * fix it. The description should be clear enough for developers to understand and resolve the | ||
| * issue. | ||
| * | ||
| * <p>Examples of field violation descriptions: | ||
| * | ||
| * <ul> | ||
| * <li>"Field is required and cannot be empty" | ||
| * <li>"Value must be a positive integer" | ||
| * <li>"Invalid email format" | ||
| * <li>"String length must be between 1 and 100 characters" | ||
| * <li>"Unsupported enum value. Must be one of: [A, B, C]" | ||
| * <li>"Field cannot contain special characters" | ||
| * <li>"Date must be in ISO 8601 format (YYYY-MM-DD)" | ||
| * </ul> | ||
| * | ||
| * @return description of why the field is invalid | ||
| */ | ||
| @JsonProperty("description") | ||
| public abstract String description(); | ||
|
|
||
| /** | ||
| * Creates a new builder for constructing BadRequestFieldViolation instances. | ||
| * | ||
| * @return a new builder instance | ||
| */ | ||
| public static Builder builder() { | ||
| return new AutoValue_BadRequest_BadRequestFieldViolation.Builder(); | ||
| } | ||
|
|
||
| /** Builder for constructing BadRequestFieldViolation instances. */ | ||
| @AutoValue.Builder | ||
| @JsonIgnoreProperties(ignoreUnknown = true) | ||
| public abstract static class Builder { | ||
|
|
||
| /** | ||
| * Sets the field path. | ||
| * | ||
| * @param field the path to the violating field | ||
| * @return this builder for method chaining | ||
| */ | ||
| @JsonProperty("field") | ||
| public abstract Builder setField(String field); | ||
|
|
||
| /** | ||
| * Sets the violation description. | ||
| * | ||
| * @param description description of why the field is invalid | ||
| * @return this builder for method chaining | ||
| */ | ||
| @JsonProperty("description") | ||
| public abstract Builder setDescription(String description); | ||
|
|
||
| /** | ||
| * Builds the BadRequestFieldViolation instance. | ||
| * | ||
| * @return a new BadRequestFieldViolation instance | ||
| */ | ||
| public abstract BadRequestFieldViolation build(); | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.