[PLUGIN-1848] Error Management for File plugin Source/Sink#1912
[PLUGIN-1848] Error Management for File plugin Source/Sink#1912psainics merged 1 commit intocdapio:developfrom
Conversation
1e92b0c to
4bb60cf
Compare
a2cd069 to
d25f116
Compare
3d77a35 to
a7b066a
Compare
| throw new IllegalArgumentException(errorMessage, e); | ||
| } catch (InstantiationException e) { | ||
| context.getFailureCollector().addFailure( | ||
| String.format("Could not find the '%s' input format.", fileFormat), null) |
There was a problem hiding this comment.
Could not load the input format %s
| try { | ||
| job = JobUtils.createInstance(); | ||
| } catch (IOException e) { | ||
| collector.addFailure("Failed to create job instance.", e.getMessage()) |
There was a problem hiding this comment.
e.getMessage() is not a corrective action:
collector.addFailure(String.format("Failed to create job instance, %s: %s", e.getClass().getName(), e.getMessage()), null)
This comment applies to whole PR.
| schema = schemaDetector.detectSchema(config.getPath(context), pattern, | ||
| formatContext, getFileSystemProperties(null)); | ||
| } catch (IOException e) { | ||
| collector.addFailure("Error when trying to detect schema: " + e.getMessage(), null) |
There was a problem hiding this comment.
collector.addFailure(String.format("Failed to auto-detect schema, %s: %s", e.getClass().getName(), e.getMessage()), null)
| @@ -243,7 +284,14 @@ protected ValidatingInputFormat getInputFormatForRun(BatchSourceContext context) | |||
| + "or re-create the pipeline with all required properties.", | |||
| fileFormat, properties); | |||
| throw new IllegalArgumentException(errorMessage, e); | |||
There was a problem hiding this comment.
please convert IllegalArgumentException to ProgramFailureException.
| Map<String, String> outputProperties = new HashMap<>(validatingOutputFormat.getOutputFormatConfiguration()); | ||
| outputProperties.putAll(getFileSystemProperties(context)); | ||
| outputProperties.put(FileOutputFormat.OUTDIR, getOutputDir(context)); | ||
| context.setErrorDetailsProvider(new ErrorDetailsProviderSpec(getErrorDetailsProviderClassName())); |
There was a problem hiding this comment.
since GCSBatchSink does not override getErrorDetailsProviderClassName(), this will get set to null, see here: https://github.com/data-integrations/google-cloud/blob/77e0ac8a386d12b7b55f7e9fab2b1adaa88d9a01/src/main/java/io/cdap/plugin/gcp/gcs/sink/GCSBatchSink.java#L168-L172
Please check getErrorDetailsProviderClassName is not null or empty and then only set it.
similar for AbstractFileBatchSource
There was a problem hiding this comment.
| return GSON.fromJson(fileSystemProperties, MAP_TYPE); | ||
| } catch (JsonSyntaxException e) { | ||
| throw new IllegalArgumentException("Unable to parse filesystem properties: " + e.getMessage(), e); | ||
| throw new IllegalArgumentException( |
There was a problem hiding this comment.
throw ProgramFailureException instead
core-plugins/src/main/java/io/cdap/plugin/batch/source/FileErrorDetailsProvider.java
Show resolved
Hide resolved
core-plugins/src/main/java/io/cdap/plugin/common/HydratorErrorDetailsProvider.java
Show resolved
Hide resolved
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Error details provided for the Snowflake |
| try { | ||
| fileStatus = pathFileSystem.globStatus(path); | ||
| } catch (IOException e) { | ||
| collector.addFailure("Failed to get file status for path " + path, e.getMessage()) |
There was a problem hiding this comment.
use String.format everywhere.
e.getMessage(), is not a correctiveAction
also preserve error class name,
%s: %s, e.getClass().getName(), e.getMessage()
| fileFormat, properties); | ||
| throw new IllegalArgumentException(errorMessage, e); | ||
| } catch (InstantiationException e) { | ||
| context.getFailureCollector().addFailure( |
There was a problem hiding this comment.
create a local variable collector = context.getFailureCollector() and use at other places in same method.
| String.format("Could not find the '%s' input format.", fileFormat), null) | ||
| .withPluginNotFound(fileFormat, fileFormat, ValidatingInputFormat.PLUGIN_TYPE) | ||
| .withStacktrace(e.getStackTrace()); | ||
| context.getFailureCollector().getOrThrowException(); |
There was a problem hiding this comment.
throw collector.getOrThrowException();
This way you wouldn't need to return null at the end.
875e48f to
8923a7d
Compare
| * @param exception The Exception to get the error information from. | ||
| * @return A ProgramFailureException with the given error information. | ||
| */ | ||
| private ProgramFailureException getProgramFailureException(Exception exception, ErrorContext errorContext, |
There was a problem hiding this comment.
private ProgramFailureException getProgramFailureException(IllegalArgumentException exception, ErrorContext errorContext,
| context.getFailureCollector().getOrThrowException(); | ||
| } | ||
| return null; |
| + "were invalid when the pipeline was deployed. Set the format to a " | ||
| + "different value, or re-create the pipeline with all required properties.", | ||
| fileFormat, properties); | ||
| throw new IllegalArgumentException(errorMessage, e); |
There was a problem hiding this comment.
similar comment to throw ProgramFailureException
| e.getMessage()); | ||
| throw ErrorUtils.getProgramFailureException( | ||
| new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), errorMessage, errorMessage, | ||
| ErrorType.SYSTEM, false, null); |
8923a7d to
bc96350
Compare
| } catch (JsonSyntaxException e) { | ||
| throw new IllegalArgumentException("Unable to parse filesystem properties: " + e.getMessage(), e); | ||
| String errorMessage = String.format( | ||
| "Failed to parse filesystem properties %s with message: %s", fileSystemProperties, |
There was a problem hiding this comment.
can we please follow the same format everywhere? %s : %s", e.getClass().getName(), e.getMessage()
331d51b to
6fb4e61
Compare
6fb4e61 to
6f4b5d8
Compare
| } catch (JsonSyntaxException e) { | ||
| throw new IllegalArgumentException("Unable to parse filesystem properties: " + e.getMessage(), e); | ||
| String errorMessage = String.format( | ||
| "Failed to parse filesystem properties %s with message: %s: %s", fileSystemProperties, |
There was a problem hiding this comment.
"Failed to parse filesystem properties %s, %s: %s"
| return GSON.fromJson(fileSystemProperties, MAP_STRING_STRING_TYPE); | ||
| } catch (Exception e) { | ||
| throw new IllegalArgumentException("Unable to parse filesystem properties: " + e.getMessage(), e); | ||
| throw new IllegalArgumentException(String.format("Unable to parse filesystem properties: %s", e.getMessage()), e); |
There was a problem hiding this comment.
"Unable to parse filesystem properties, %s: %s", e.getClass().getName(), e.getMessage()
|
Please add a JIRA in the title |
https://cdap.atlassian.net/browse/PLUGIN-1848
[ { "stageName": "File", "errorCategory": "Plugin-'File'", "errorReason": "Input path /Users/pusaini/wsf/cdap/env/group_by_test_data_1/data.csv does not exist", "errorMessage": "Input path /Users/pusaini/wsf/cdap/env/group_by_test_data_1/data.csv does not exist", "errorType": "USER", "dependency": "false" }, { "errorCategory": "Plugin", "errorReason": "Input path /Users/pusaini/wsf/cdap/env/group_by_test_data_1/data.csv does not exist", "errorMessage": "Input path /Users/pusaini/wsf/cdap/env/group_by_test_data_1/data.csv does not exist", "errorType": "USER", "dependency": "false" } ]