[hma] Add note field to BankContent with storage layer support#1931
[hma] Add note field to BankContent with storage layer support#1931sreeprasad wants to merge 1 commit intofacebook:mainfrom
Conversation
Part of facebook#1925 - Add notes to hashbank content Changes: - Add column (VARCHAR 255) to bank_content table - Add database migration - Update BankContentConfig dataclass with note field - Update storage implementation (add, get, update) - Update mocked storage - Add unit tests for note CRUD operations - Fix devcontainer Dockerfile yarn GPG key issue
|
Hi @sreeprasad! Thank you for your pull request and welcome to our community. Action RequiredIn order to merge any pull request (code, docs, etc.), we require contributors to sign our Contributor License Agreement, and we don't seem to have one on file for you. ProcessIn order for us to review and merge your suggested changes, please sign at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need to sign the corporate CLA. Once the CLA is signed, our tooling will perform checks and validations. Afterwards, the pull request will be tagged with If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks! |
| FROM mcr.microsoft.com/vscode/devcontainers/python:3.13-bullseye | ||
|
|
||
| RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \ | ||
| RUN rm -f /etc/apt/sources.list.d/yarn.list \ |
There was a problem hiding this comment.
blocking q: What is this change for? Consider documenting what this is for.
| assert val == example_metadata | ||
|
|
||
|
|
||
| def test_bank_content_note(storage: DefaultOMMStore) -> None: |
There was a problem hiding this comment.
ignorable: You probably could get away with adding setting the note to the existing tests.
A pattern I usually think works and is compact is:
- Test creating with all defaults
- Test setting all settable fields
- Test setting one field, all other fields are unset
- Test creating with all field set
| assert content_configs[0].note is None | ||
|
|
||
|
|
||
| def test_bank_content_note_max_length(storage: DefaultOMMStore) -> None: |
There was a problem hiding this comment.
blocking: Add a case that demonstrates the behavior creating over the max length. The test as written I don't think tests anymore more than the previous test does
|
@Dcallies I wonder if this PR as-is would be a breaking change for folks. My thinking is - when folks update they first need to run the migrations before we can update the code to use the new field; we can't assume in the code that the migration has already ran. What do you think? |
|
@aokolish - making sure I understand your question correctly, are you asking if this change will require a database schema update to work? If so, then yes, it will, and that's what we use the alembic library for. The expectation is that you use alembic to upgrade the schemas of your database when upgrading to new versions. You can see the created migration file in the PR. |
|
Nope, I know that it requires the schema change. I'm wondering about downtime / errors. My question is - is there a way we can we ship this with no down time? Here's what I think will happen if we merge this and an HMA user updates:
There may not be a good way to avoid this, but lmk if you think I'm missing something. If HMA were not open source, what I would do is...
Maybe we could avoid the errors by splitting this into 2 PRs and 2 different HMA tags (then we could deploy them separately). You think it's worth the effort? Or, am I missing something? |
Part of #1925 - Add notes to hashbank content
Changes:
Summary
Adds a
notefield to BankContent allowing users to attach context when adding content to a bank (e.g., "Reported by user X" or "Part of campaign ABC").This PR implements the database and storage layer changes:
notecolumn (VARCHAR 255) onbank_contenttableAlso fixes a yarn GPG key issue in the devcontainer Dockerfile.
Part of #1925
Test Plan
test_bank_content_note- tests add, read, update, and clear notetest_bank_content_note_max_length- tests 255 character limitpy.test