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

[ODS-5581] Bring dynamic profile spike work to current codebase #581

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

gmcelhanon
Copy link
Contributor

No description provided.

…n already implemented for DataManagementRequestContext.
…ted boilerplate version already implemented for DataManagementRequestContext.
…ion on code repository path string parsing failures.
…ngle static FullName value (rather than creating a new one every time).
: 0);

hashCode = (hashCode * 397) ^ ProfileResourceName.GetHashCode();
hashCode = (hashCode * 397) ^ (int)ContentTypeUsage;
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to use System.HashCode instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This undoubtedly was generated by Rider/ReSharper. Are you suggesting not implementing the method at all, or are you referring to the cast to int on the ContentTypeUsage?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI: I just ran a Linqpad expression and 7.GetHashCode() returns 7.

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant using the new HashCode.Combine to calculate the hash code, the logic is the same but it produces cleaner code. ReSharper already uses it by default.
I'm good with the current implementation, I was just wondering if there were any reasons not to use HashCode.Combine.

@gmcelhanon gmcelhanon changed the base branch from main to ODS-5616 October 20, 2022 21:45
Copy link
Contributor

@AxelMarquez AxelMarquez left a comment

Choose a reason for hiding this comment

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

Since we no longer generate Profile controllers, GetReadContentType doesn't get overridden, so the response content-type is always application/json regardless if it's a Profile request.

We can check the ProfileContentTypeContext to return the appropriate content-type.

return ContentTypeUsage.Writable;
}

throw new BadRequestException($"The profile usage segment in the profile-based '{headerName}' header was not recognized.");
Copy link
Contributor

Choose a reason for hiding this comment

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

This returns HTTP 500 instead of 400. I didn't test the other errors but most likely have the same behaviour.
image

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So the work to address this goes a little deeper than we need to for this spike ticket. This middleware is running at a much lower level in the processing than the fallback exception translation (the ExceptionHandlingFilter).

I've added a comment to the ticket for updating the Profiles Postman tests to ensure we don't forget to address this when it comes time to work on the ticket to prepare the branch for final merge to main with ODS-5611.

Copy link
Contributor Author

@gmcelhanon gmcelhanon Nov 6, 2022

Choose a reason for hiding this comment

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

I have added Postman tests in the "Profiles" test suite covering these scenarios, specifically:

  • Expecting a 400 response status with the exception message above in the message property of the response (for both read and write requests) when the content type usage is not either readable or writable.
  • Expecting a profile-specific Content-Type response header for both Get All and Get By Id requests (Get By Id scenario fails against current main branch).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Covering tests have been moved into the main Profiles Suite now, and are passing (with commits added to ODS-5610 branch, which is based on this one).

Base automatically changed from ODS-5616 to main January 26, 2023 17:26
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.

2 participants