Skip to content
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

feat: tracker import errors to job tracking error forward [DHIS2-15276] #15723

Merged
merged 6 commits into from
Nov 20, 2023

Conversation

jbee
Copy link
Contributor

@jbee jbee commented Nov 16, 2023

Summary

Adjustments to the job progress error tracking for tracker import jobs.
This does add error transfer from the ValidationReport to the job progress errors.

Since two different enums are used as source of error codes, ErrorCode and ValidationCode the job progress API got addError methods which accept one or the other. Internally the code is then stored as String.
A client can distinguish the codes based on the added codes property to the root object of /api/jobConfigurations/errors.
The value can be understood as a sort of namespace or part of a translation key root or path segment.

The input that caused an error can now be included using includeInput flag parameter, for example: /api/jobConfigurations/errors?includeInput=true

The tracker input file storage format changed from binary (java serialisation) to JSON so it can be included in the JSON as described above.

The tracker Error created from a validation error now included the plain argument list as this is needed when transferring errors to the job progress error tracking which does not store the message but adds it on the fly for API requests based on the error code and the args.

Automatic Testing

Existing tests got adjusted, mostly to provide the args list.

A new test scenario was added that runs a tracker import with error and checks the error endpoint with the includeInput to verify both that tracker errors are transferred and that the input inclusion works.

Manual Testing

  • create a tracker import: POST to /api/tracker?async=true with a JSON payload with errors, for example
{
    "trackedEntities": [
        {
            "trackedEntity":"sHH8mh1Fn0z",
            "trackedEntityType": "nEenWmSyUEp",
            "orgUnit": "DiszpKrYNg8"
        }
    ]
}
  • find the created job, e.g. api/jobConfigurations/gist?filter=jobType:eq:TRACKER_IMPORT_JOB&order=created:desc
  • check the errors api/jobConfigurations/errors?includeInput=true has an entry for the job and also includes the input JSON as input (note that this is not 1:1 of the original JSON send but a JSON for a intermediate format based on TrackerObjects type)

@jbee jbee self-assigned this Nov 16, 2023
Copy link

codecov bot commented Nov 16, 2023

Codecov Report

Merging #15723 (3abb958) into master (5b0cc8e) will increase coverage by 0.00%.
Report is 8 commits behind head on master.
The diff coverage is 66.66%.

Additional details and impacted files
@@            Coverage Diff            @@
##             master   #15723   +/-   ##
=========================================
  Coverage     66.27%   66.28%           
- Complexity    31326    31368   +42     
=========================================
  Files          3484     3486    +2     
  Lines        129987   129973   -14     
  Branches      15192    15201    +9     
=========================================
- Hits          86155    86151    -4     
+ Misses        36742    36731   -11     
- Partials       7090     7091    +1     
Flag Coverage Δ
integration 50.01% <62.74%> (+<0.01%) ⬆️
integration-h2 32.34% <0.00%> (+0.04%) ⬆️
unit 30.27% <25.49%> (+<0.01%) ⬆️

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

Files Coverage Δ
...his/tracker/imports/validation/ValidationCode.java 100.00% <ø> (ø)
...his/scheduling/DefaultJobSchedulerLoopService.java 53.50% <100.00%> (-0.41%) ⬇️
...sp/dhis/scheduling/DefaultJobSchedulerService.java 27.27% <100.00%> (-6.07%) ⬇️
...org/hisp/dhis/scheduling/RecordingJobProgress.java 72.64% <100.00%> (+0.23%) ⬆️
...va/org/hisp/dhis/tracker/imports/report/Error.java 100.00% <100.00%> (ø)
.../dhis/tracker/imports/report/ValidationReport.java 96.55% <100.00%> (+0.06%) ⬆️
...rg/hisp/dhis/tracker/imports/validation/Error.java 100.00% <100.00%> (ø)
...tracker/imports/validation/PersistablesFilter.java 96.74% <100.00%> (ø)
.../webapi/controller/metadata/MetadataImportJob.java 88.00% <100.00%> (ø)
...hisp/dhis/tracker/imports/validation/Reporter.java 89.36% <50.00%> (-1.95%) ⬇️
... and 4 more

... and 103 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5b0cc8e...3abb958. Read the comment docs.

@jbee jbee requested a review from enricocolasante November 20, 2023 09:20
@jbee jbee marked this pull request as ready for review November 20, 2023 09:20
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

@@ -47,6 +47,7 @@
import lombok.*;
import lombok.experimental.Accessors;
import org.hisp.dhis.feedback.ErrorCode;
import org.hisp.dhis.tracker.imports.validation.ValidationCode;
Copy link
Contributor

Choose a reason for hiding this comment

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

not related to your changes but there are some wildcard imports in this file. maybe can clean up later.

import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

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

wildcard import

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch, I have not done all my setup after reinstalling recently. I make a fix PR

JobConfiguration obj = jobConfigurationService.getJobConfigurationByUid(uid.getValue());
if (obj == null) throw new NotFoundException(JobConfiguration.class, uid.getValue());
boolean canCancel =
currentUser.isSuper()
Copy link
Contributor

Choose a reason for hiding this comment

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

this is just a micro thing but maybe worth to note that User.isSuper() is a heavy operation, maybe better to make it the last condition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I keep that in mind, also it is surprising to me.

@jbee jbee merged commit 7fd3140 into dhis2:master Nov 20, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants