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: remove audited methods from api client and add them directly to… #182

Merged
merged 2 commits into from
Jun 21, 2024

Conversation

andrey-canon
Copy link
Collaborator

Description

This removes the auditable wrappers from the api_client file and move them to the corresponding pipe, this preserves the current output format however the input format has changed, this uses a dict format instead of a SOAP string.

Before

CDD
image

EAD
image

After

CDD
image

EAD
image

Additional information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.

Checklist for Merge

  • Tested in a remote environment
  • Updated documentation
  • Rebased master/main
  • Squashed commits

@johanseto johanseto self-assigned this Jun 20, 2024
@johanseto johanseto self-requested a review June 20, 2024 22:25
@github-actions github-actions bot added the size/m m lines label label Jun 20, 2024
Copy link
Collaborator

@johanseto johanseto left a comment

Choose a reason for hiding this comment

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

LGTM. It takes advantage that pipe step doesn't receive the credentials in kwargs.

"soapenv:Envelope": {
                "soapenv:Header": {
                    "wsse:Security": {
                        "wsse:UsernameToken"
...
}

I thought that we would refactor it into a step pipe like set_pearson_credentials.
But in this case we have to adapt or adjust to the eox_audit model, that save the kwargs.


# There are multiple kind of errors, some of them generates a soapenv:Fault section and others
# generates an status error section, the following condition handles the first case.
if fault:
return {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe here we could add an exception. To try to add the eox_audit with the failure status instead of success.
I was thinking of the audit error raising a pearsonExceptionm but it would be twice I think so... or may be not.
We have to view it after the PearsonException PR works...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@johanseto please check the last commit, I moved the exception inside the auditable method and now the error output looks like this
image
image


return {
"status": "unexpected error",
"response": xml_response,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that any error would be returned without changes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the current implementation :)

# pylint: disable=broad-exception-raised
raise Exception("Error trying to process import exam authorization request.")
raise Exception(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I like that this Exception gives the Fail status, but what do you think of the retry of the error like 4 times because it is en celery async environment.
I think that it would retry 4 times, saving the 4 Fail record. The good news is that now it is easier to distinguish than the success records.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Short answer out of the scope, long answer I was thinking to implement a PearsonBaseError here and limit the retrying process just to the ping pipeline since other case will need that a user o someone changes something so it's not necessary multiple attempts

Copy link
Collaborator

Choose a reason for hiding this comment

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

I really like that comment.

@johanseto johanseto self-requested a review June 21, 2024 21:04
@johanseto
Copy link
Collaborator

Approved

@andrey-canon andrey-canon merged commit 3ce2414 into master Jun 21, 2024
7 checks passed
@andrey-canon andrey-canon deleted the and/remove_sensitive_data branch July 16, 2024 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/m m lines label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants