Skip to content

started adding transmittable for the VLP REST XML#176

Draft
kristinmerbach wants to merge 6 commits intotrunkfrom
186675775_vlp_transmittable
Draft

started adding transmittable for the VLP REST XML#176
kristinmerbach wants to merge 6 commits intotrunkfrom
186675775_vlp_transmittable

Conversation

@kristinmerbach
Copy link
Copy Markdown
Contributor

@kristinmerbach kristinmerbach commented Dec 13, 2023

Summary by CodeRabbit

  • New Features

    • Introduced a new data model for handling personal information with enhanced indexing for improved search and retrieval.
    • Added a new XML payload field to transactions for extended data handling capabilities.
    • Implemented a comprehensive job operation for generating transmittable verification payloads.
    • Refined the initial verification request process with updated error handling and response publishing.
  • Enhancements

    • Streamlined the verification response processing by integrating with a new module for better data management.
    • Upgraded the verification request operation with a new event publishing mechanism for REST XML.
  • Refactor

    • Restructured the transformation of personal data to initial request format for increased efficiency and reliability.
    • Overhauled the XML request transformation process with additional validation and encoding steps for improved data integrity.

@kristinmerbach kristinmerbach marked this pull request as draft December 13, 2023 23:29
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 13, 2023

Important

Auto Review Skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository.

To trigger a single review, invoke the @coderabbitai review command.

Walkthrough

The updates involve the introduction of a new Transmittable module with a Person class and changes to the Transaction class. There's a significant overhaul in the FDSH VLP operations, with new job payload generation, request handling, response processing, and XML transformation logic. These changes suggest a focus on enhancing data handling, improving verification processes, and refining the system's ability to process and transmit information.

Changes

Files Change Summary
.../transmittable/person.rb
.../transmittable/transaction.rb
Introduced Transmittable module with new Person class and added xml_payload field to Transaction class.
.../generate_transmittable_vlp_payload.rb
.../handle_initial_verification_request.rb
.../process_initial_verification_response.rb
.../request_vlp_verification.rb
.../transform_person_to_initial_request.rb
.../transform_person_to_xml_request.rb
Overhauled FDSH VLP operations with new payload generation, request handling, response processing, and XML transformation logic.

🐇✨
Code hops along, new features in sight,
Modules and classes, they all take flight.
With each new line, the system grows,
A rabbit's touch, and the magic flows. 🌟🌙

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can reply to a review comment made by CodeRabbit.
  • You can tag CodeRabbit on specific lines of code or files in the PR by tagging @coderabbitai in a comment.
  • You can tag @coderabbitai in a PR comment and ask one-off questions about the PR and the codebase. Use quoted replies to pass the context for follow-up questions.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 9c58722 and c9a59fe.
Files selected for processing (8)
  • app/models/transmittable/person.rb (1 hunks)
  • app/models/transmittable/transaction.rb (1 hunks)
  • app/operations/fdsh/jobs/generate_transmittable_vlp_payload.rb (1 hunks)
  • app/operations/fdsh/vlp/rx92/handle_initial_verification_request.rb (1 hunks)
  • app/operations/fdsh/vlp/rx92/process_initial_verification_response.rb (1 hunks)
  • app/operations/fdsh/vlp/rx92/request_vlp_verification.rb (1 hunks)
  • app/operations/fdsh/vlp/rx92/transform_person_to_initial_request.rb (1 hunks)
  • app/operations/fdsh/vlp/rx92/transform_person_to_xml_request.rb (1 hunks)
Files skipped from review due to trivial changes (1)
  • app/operations/fdsh/vlp/rx92/request_vlp_verification.rb
Additional comments: 28
app/models/transmittable/transaction.rb (5)
  • 37-37: The addition of the xml_payload field to the Transaction class aligns with the PR objectives to enhance VLP REST XML functionality.

  • 37-37: Verify that ::Transmittable::Transmission.define_transmission_constants is called before the transmit_action= and status= methods to ensure the constants are defined.

  • 37-37: Ensure that the transactions_transmissions association and the transmission method in TransactionsTransmissions are correctly implemented to support the logic in the transmission method.

  • 37-37: Confirm that all possible transactable objects have either an hbx_id or an hbx_assigned_id attribute to prevent potential NoMethodError in the subject_hbx_id method.

  • 37-37: Verify that the errors method exists and that transmittable_errors is an enumerable collection that responds to map to support the error_messages method.

app/operations/fdsh/jobs/generate_transmittable_vlp_payload.rb (8)
  • 9-17: The main call method orchestrates the payload generation process. It sequentially calls private methods to validate parameters, create a job, create a transmission, create a person subject, create a transaction, and generate a transmittable payload. The flow appears logical and follows the expected steps for the operation.

  • 21-26: The validate_params method checks for the presence and type of required parameters. It's important to ensure that all callers of this operation are updated to pass the correct types and that the parameters are sanitized before being passed to this method to prevent any security issues.

  • 31-40: The create_job method delegates job creation to Fdsh::Jobs::FindOrCreateJob and handles the result. It's crucial to ensure that generate_message_id on line 36 is idempotent or that it's acceptable to change the message ID if the job already exists.

  • 43-50: The create_transmission method creates a transmission and handles errors by updating the status and adding errors. It's important to verify that the update_status and add_errors methods are correctly logging and handling errors, and that the error messages do not leak any PII.

  • 60-81: The create_person_subject method looks for an existing person by correlation_id and creates a new one if not found. It's important to ensure that the correlation_id is indexed for performance and that the encrypted_ssn is handled securely throughout the system.

  • 84-93: The create_transaction method creates a transaction and handles errors similarly to the create_transmission method. It's important to verify that the transaction creation process is atomic and that any failure in this process does not leave the system in an inconsistent state.

  • 96-118: The generate_transmittable_payload method transforms the payload to XML and updates the transaction. It's important to ensure that the transformation process is secure and that the XML payload does not contain any sensitive information unless it's properly encrypted or sanitized.

  • 121-134: The transmittable method checks if the transaction has an XML payload and a message ID, then returns success or failure accordingly. It's important to ensure that the message ID generation is secure and that it cannot be exploited to infer or predict other message IDs.

app/operations/fdsh/vlp/rx92/handle_initial_verification_request.rb (10)
  • 11-26: The main call method orchestrates the VLP request handling process. It appears to be well-structured, chaining operations with monadic yield statements for a clear flow of data and error handling.

  • 30-34: The validate_params method checks for the presence of correlation_id and payload. It's important to ensure that all required parameters are validated here to prevent processing incomplete or invalid requests.

  • 37-46: The transmittable_payload method delegates to GenerateTransmittableVlpPayload and handles the result. It's crucial that GenerateTransmittableVlpPayload is thoroughly tested to ensure it can handle all expected input cases.

  • 49-63: The generate_jwt method generates a JWT and updates the status based on the result. It's important to verify that the Jwt::GetJwt service is robust and that the error handling here is comprehensive.

  • 66-82: The publish_vlp_request method sends the VLP request and updates the status accordingly. It's critical to ensure that the RequestVlpVerification service is reliable and that the error messages are informative for debugging purposes.

  • 85-105: The create_response_transmission method creates a transmission record for the response. It's important to ensure that the CreateTransmission service is well-tested and that the error handling is sufficient.

  • 108-131: The create_response_transaction method creates a transaction record for the response and assigns the XML payload. It's important to verify that the XML payload is being assigned correctly and that the transaction is saved properly.

  • 155-170: The process_response method processes the VLP response. It's critical to ensure that the ProcessInitialVerificationResponse service is thoroughly tested and that the status updates and error handling are robust.

  • 174-185: The build_event and publish methods are responsible for building and publishing the event after processing the VLP response. It's important to ensure that the event payload is structured correctly and that the event is published successfully.

  • 188-193: The add_errors and update_status methods are utility methods for error logging and status updating. It's important to verify that these methods are called with the correct parameters and that they function as expected in all scenarios.

app/operations/fdsh/vlp/rx92/transform_person_to_xml_request.rb (5)
  • 13-19: The call method orchestrates the transformation of a person's JSON payload to XML. It sequentially parses JSON, validates the person hash, builds a person object, transforms it to an initial request, and finally encodes it to XML. Ensure that each step includes adequate error handling and that the transformations align with the expected VLP XML format.

  • 33-35: The comment on line 34 suggests that the encode_xml_and_schema_validate method is a placeholder and will be replaced. Ensure that the replacement is tracked and implemented before finalizing the feature to avoid deploying temporary code to production.

  • 38-46: The encode_request_xml method encodes the XML string and sets the encoding to 'UTF-8'. Ensure that the encoding specified here is consistent with the rest of the system and that the XML declaration is intentionally omitted as per the requirements of the VLP system.

  • 49-52: The validate_person_json_hash method uses AcaEntities::Contracts::People::PersonContract for validation. Ensure that the contract is up-to-date with the latest VLP requirements and that all necessary fields are validated.

  • 55-62: The build_person method constructs a Person object from the validated hash. Ensure that the Person entity is correctly mapped to the VLP requirements and that all necessary attributes are included.

Comment on lines +28 to +29
Failure(
"Invalid person, given value is not a ::AcaEntities::People::Person, input_value:#{person}"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The error message in the Failure response could be more informative by including the actual class of the input object when it's not a ::AcaEntities::People::Person.

- "Invalid person, given value is not a ::AcaEntities::People::Person, input_value:#{person}"
+ "Invalid person, given value is not a ::AcaEntities::People::Person, input_value:#{person.class}"

Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
Failure(
"Invalid person, given value is not a ::AcaEntities::People::Person, input_value:#{person}"
Failure(
"Invalid person, given value is not a ::AcaEntities::People::Person, input_value:#{person.class}"

Comment on lines +6 to +7
# This class takes a json representing a person as input and invokes RIDP.
class TransformPersonToXmlRequest
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The class description mentions invoking RIDP, but the code does not seem to reflect any direct interaction with RIDP. Ensure that the comment accurately describes the class's purpose or update it to reflect the current functionality.

Comment on lines +24 to +30
def parse_json(json_string)
parsing_result = Try do
JSON.parse(json_string, :symbolize_names => true)
end
parsing_result.or do
Failure(:invalid_json)
end
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The parse_json method uses a Try block to parse the JSON string, which is good for error handling. However, the failure case only returns a symbol :invalid_json. Consider providing more context or logging for the failure to aid in debugging.

# @return [Dry::Monads::Result]
def call(xml_response)
parsed_xml = yield process_xml(xml_response)
# we should move all the construction into aca_entities rather than having it in FDSH
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot Dec 13, 2023

Choose a reason for hiding this comment

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

Comments within the code indicate future refactoring plans. It's best practice to track these outside the code, such as in a project management tool, to keep the codebase clean.

- # we should move all the construction into aca_entities rather than having it in FDSH
- # we should move all the validation into aca_entities rather than having it in FDSH

Also applies to: 24-24, 39-39


Committable suggestion

IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.

Suggested change
# we should move all the construction into aca_entities rather than having it in FDSH

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This PR is still a draft noting future work to do, should be left as is for now

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@kristinmerbach Understood, the comments will remain as notes for future work while the PR is in draft status. Thank you for the clarification.


If you found the review helpful, we would love if you give us a shout-out on X (twitter).

Comment on lines +62 to +95
# rubocop:disable Metrics/MethodLength
def get_individual_response_set(individual_response_set)
{
CaseNumber: individual_response_set&.CaseNumber,
NonCitLastName: individual_response_set&.NonCitLastName,
NonCitFirstName: individual_response_set&.NonCitFirstName,
NonCitMiddleName: individual_response_set&.NonCitMiddleName,
NonCitBirthDate: individual_response_set&.NonCitBirthDate,
NonCitEntryDate: individual_response_set&.NonCitEntryDate,
AdmittedToDate: individual_response_set&.AdmittedToDate,
AdmittedToText: individual_response_set&.AdmittedToText,
NonCitCountryBirthCd: individual_response_set&.NonCitCountryBirthCd,
NonCitCountryCitCd: individual_response_set&.NonCitCountryCitCd,
NonCitCoaCode: individual_response_set&.NonCitCoaCode,
NonCitProvOfLaw: individual_response_set&.NonCitProvOfLaw,
NonCitEadsExpireDate: individual_response_set&.NonCitEadsExpireDate,
EligStatementCd: individual_response_set&.EligStatementCd,
EligStatementTxt: individual_response_set&.EligStatementTxt,
IAVTypeCode: individual_response_set&.IAVTypeCode,
IAVTypeTxt: individual_response_set&.IAVTypeTxt,
WebServSftwrVer: individual_response_set&.WebServSftwrVer,
GrantDate: individual_response_set&.GrantDate,
GrantDateReasonCd: individual_response_set&.GrantDateReasonCd,
SponsorDataFoundIndicator: individual_response_set&.SponsorDataFoundIndicator,
ArrayOfSponsorshipData: construct_sponsorship_data(individual_response_set&.ArrayOfSponsorshipData),
SponsorshipReasonCd: individual_response_set&.SponsorshipReasonCd,
AgencyAction: individual_response_set&.AgencyAction,
FiveYearBarApplyCode: individual_response_set&.FiveYearBarApplyCode,
QualifiedNonCitizenCode: individual_response_set&.QualifiedNonCitizenCode,
FiveYearBarMetCode: individual_response_set&.FiveYearBarMetCode,
USCitizenCode: individual_response_set&.USCitizenCode
}
end
# rubocop:enable Metrics/MethodLength
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The methods are quite long, which is acknowledged by disabling Rubocop's Metrics/MethodLength. Consider refactoring to reduce method complexity and improve maintainability.

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