-
Notifications
You must be signed in to change notification settings - Fork 69
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
Validate document attachments at time of upload #19532
Conversation
4fa46a2
to
207c8df
Compare
90b62ce
to
f6e2287
Compare
afbc386
to
ecd15ee
Compare
ecd15ee
to
bc56c8b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like some tests are failing, and one question
Generated by 🚫 Danger |
3af220b
to
b09b70c
Compare
b09b70c
to
39fff39
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a few more changes and some questions
|
||
raise Common::Exceptions::ValidationErrors, attachment unless attachment.valid? | ||
if Flipper.enabled?(:document_upload_validation_enabled) && !stamped_pdf_valid? && | ||
%w[21P-527EZ 21P-530 21P-530V2].include?(form_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the form_id check should come first in the conditional list, so if that fails the later ones will not be checked. will prevent an unneeded stamped_pdf_valid?
call
unless allowed_types.include?(extension) | ||
raise Common::Exceptions::UnprocessableEntity.new( | ||
detail: I18n.t('errors.messages.extension_allowlist_error', extension:, allowed_types:), | ||
source: 'PersistentAttachment.unlock_file' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this need to be updated?
also, add a separate check here for an empty file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I found from running our specs that trying to convert txt files into PDF caused issues within pdftk, hence the extra enforcement of file type here. i'll add a check for empty file here now
lib/claim_documents/monitor.rb
Outdated
# | ||
class Monitor < ::Logging::Monitor | ||
# statsd key for document uploads | ||
DOCUMENT_STATS_KEY = 'api.document_upload' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
api.claim_documents
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wayne-weibel sure, i can rename it. But we'll also need to remember to update the key name on the widget @balexandr created in Datadog as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
removing in favor of spec/requests/v0/claim_documents_spec.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be a separate spec? it seems redundant to spec/controllers/v0/claim_documents_controller_spec.rb
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wayne-weibel that could be why spec/controllers/v0/claim_documents_controller_spec.rb
didn't exist in the first place. I can remove that spec file then, to reduce redundancy.
2a528d9
to
0319295
Compare
0319295
to
243dbba
Compare
* Validate document attachments at time of upload * Added flipper for extra validation steps --------- Co-authored-by: Wayne Weibel <wayne.weibel@adhocteam.us>
Summary
Related issue(s)
Testing done
Screenshots
Note: Optional
What areas of the site does it impact?
(Describe what parts of the site are impacted andifcode touched other areas)
Acceptance criteria
Requested Feedback
(OPTIONAL)What should the reviewers know in addition to the above. Is there anything specific you wish the reviewer to assist with. Do you have any concerns with this PR, why?