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

Updated File Upload to Auto Encode to UTF-8 #3438

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

elipe17
Copy link

@elipe17 elipe17 commented Jan 21, 2025

Summary of Changes

  • Added new package to the frontend to better handle data file encoding errors
  • Updated FileUpload.jsx to use the new package to detect and subsequently transcode datafiles if they are not utf8 format

Pull request closes #2854

How to Test

List the steps to test the PR
These steps are generic, please adjust as necessary.

cd tdrs-frontend && docker-compose up --build
cd tdrs-backend && docker-compose up
  1. Open http://localhost:3000/ and sign in.
  2. Upload/submit a normal datafile to verify functionality
  3. Take the same datafile open it in VS code. In the bottom right of VS code, you will see the encoding of the file. Click that and then select Save with Encoding. Choose a few encodings and submit each file as you change the encoding.
  4. Verify that the file is uploaded, the backend doesn't report an invalid encoding, and ideally no data loss has occurred and the submission history reports the same output as the original submission from step 2. Some obvious new encodings that would break develop but not this PR are: UTF-8 with BOM, UTF-16 LE, and UTF-16 BE.

Deliverables

More details on how deliverables herein are assessed included here.

Deliverable 1: Accepted Features

Checklist of ACs:

  • [insert ACs here]
  • lfrohlich and/or adpennington confirmed that ACs are met.

Deliverable 2: Tested Code

  • Are all areas of code introduced in this PR meaningfully tested?
    • If this PR introduces backend code changes, are they meaningfully tested?
    • If this PR introduces frontend code changes, are they meaningfully tested?
  • Are code coverage minimums met?
    • Frontend coverage: [insert coverage %] (see CodeCov Report comment in PR)
    • Backend coverage: [insert coverage %] (see CodeCov Report comment in PR)

Deliverable 3: Properly Styled Code

  • Are backend code style checks passing on CircleCI?
  • Are frontend code style checks passing on CircleCI?
  • Are code maintainability principles being followed?

Deliverable 4: Accessible

  • Does this PR complete the epic?
  • Are links included to any other gov-approved PRs associated with epic?
  • Does PR include documentation for Raft's a11y review?
  • Did automated and manual testing with iamjolly and ttran-hub using Accessibility Insights reveal any errors introduced in this PR?

Deliverable 5: Deployed

  • Was the code successfully deployed via automated CircleCI process to development on Cloud.gov?

Deliverable 6: Documented

  • Does this PR provide background for why coding decisions were made?
  • If this PR introduces backend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces frontend code, is that code easy to understand and sufficiently documented, both inline and overall?
  • If this PR introduces dependencies, are their licenses documented?
  • Can reviewer explain and take ownership of these elements presented in this code review?

Deliverable 7: Secure

  • Does the OWASP Scan pass on CircleCI?
  • Do manual code review and manual testing detect any new security issues?
  • If new issues detected, is investigation and/or remediation plan documented?

Deliverable 8: User Research

Research product(s) clearly articulate(s):

  • the purpose of the research
  • methods used to conduct the research
  • who participated in the research
  • what was tested and how
  • impact of research on TDP
  • (if applicable) final design mockups produced for TDP development

@elipe17 elipe17 self-assigned this Jan 21, 2025
Copy link

codecov bot commented Jan 21, 2025

Codecov Report

Attention: Patch coverage is 76.00000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 91.37%. Comparing base (3135a48) to head (2269c21).
Report is 6 commits behind head on develop.

Files with missing lines Patch % Lines
...-frontend/src/components/FileUpload/FileUpload.jsx 76.00% 5 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3438      +/-   ##
===========================================
- Coverage    91.40%   91.37%   -0.03%     
===========================================
  Files          302      302              
  Lines         8679     8689      +10     
  Branches       643      643              
===========================================
+ Hits          7933     7940       +7     
- Misses         625      628       +3     
  Partials       121      121              
Flag Coverage Δ
dev-backend 91.26% <ø> (ø)
dev-frontend 92.22% <76.00%> (-0.22%) ⬇️

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

Files with missing lines Coverage Δ
tdrs-frontend/src/actions/reports.js 100.00% <ø> (ø)
...-frontend/src/components/FileUpload/FileUpload.jsx 89.06% <76.00%> (-3.54%) ⬇️

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 3135a48...2269c21. Read the comment docs.

@elipe17 elipe17 added frontend dev raft review This issue is ready for raft review labels Jan 22, 2025
Copy link

@jtimpe jtimpe left a comment

Choose a reason for hiding this comment

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

Working as expected, and i appreciate you cleaning up the functions a bit

@lhuxraft lhuxraft added the a11y-review PR is ready for accessibility review label Jan 27, 2025
@lhuxraft lhuxraft removed the a11y-review PR is ready for accessibility review label Jan 27, 2025
Copy link

@raftmsohani raftmsohani left a comment

Choose a reason for hiding this comment

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

LGTM!

@jtimpe jtimpe mentioned this pull request Jan 28, 2025
31 tasks
@lhuxraft lhuxraft removed raft review This issue is ready for raft review QASP Review labels Jan 29, 2025
@elipe17 elipe17 requested a review from ADPennington January 29, 2025 16:47
@lhuxraft lhuxraft mentioned this pull request Feb 3, 2025
32 tasks
@lhuxraft
Copy link
Collaborator

lhuxraft commented Feb 3, 2025

@ADPennington

@ADPennington
Copy link
Collaborator

@elipe17 @lhuxraft pipeline failing on this branch.

@elipe17
Copy link
Author

elipe17 commented Feb 3, 2025

@elipe17 @lhuxraft pipeline failing on this branch.

Even though all of the tests are passing, Jest is returning a status code of 1. My assumption is that this is an async/await issue in one of the tests. We get intermittent frontend test success because we get lucky with timing. I am still looking into where this could be happening.

@ADPennington ADPennington added the Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI label Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deploy with CircleCI-qasp Deploy to https://tdp-frontend-qasp.app.cloud.gov through CircleCI dev frontend QASP Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate solutions for handling encoding errors during file upload and parsing
5 participants