Skip to content

[hma] Add note field to BankContent with storage layer support#1931

Open
sreeprasad wants to merge 1 commit intofacebook:mainfrom
sreeprasad:add-notes-to-save-additional-details
Open

[hma] Add note field to BankContent with storage layer support#1931
sreeprasad wants to merge 1 commit intofacebook:mainfrom
sreeprasad:add-notes-to-save-additional-details

Conversation

@sreeprasad
Copy link

Part of #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

Summary

Adds a note field 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:

  • New note column (VARCHAR 255) on bank_content table
  • Database migration
  • Updated storage interface and implementation
  • Unit tests for note CRUD operations

Also fixes a yarn GPG key issue in the devcontainer Dockerfile.

Part of #1925

Test Plan

  • All 46 existing tests pass
  • Added 2 new tests:
    • test_bank_content_note - tests add, read, update, and clear note
    • test_bank_content_note_max_length - tests 255 character limit
  • Tested locally in devcontainer with py.test

  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
@meta-cla
Copy link

meta-cla bot commented Feb 5, 2026

Hi @sreeprasad!

Thank you for your pull request and welcome to our community.

Action Required

In 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.

Process

In 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 CLA signed. The tagging process may take up to 1 hour after signing. Please give it that time before contacting us about it.

If you have received this in error or have any questions, please contact us at cla@meta.com. Thanks!

@github-actions github-actions bot added the hma Items related to the hasher-matcher-actioner system label Feb 5, 2026
Copy link
Contributor

@Dcallies Dcallies left a comment

Choose a reason for hiding this comment

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

Looks good, would be willing to merge as is, just some questions inline, and you'll need to accept CLA.

If you want to send back to me without making a code change, just hit "Request review" in the upper right hand.

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 \
Copy link
Contributor

Choose a reason for hiding this comment

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

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:
Copy link
Contributor

Choose a reason for hiding this comment

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

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:

  1. Test creating with all defaults
  2. Test setting all settable fields
  3. Test setting one field, all other fields are unset
  4. Test creating with all field set

assert content_configs[0].note is None


def test_bank_content_note_max_length(storage: DefaultOMMStore) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

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

@aokolish
Copy link
Collaborator

aokolish commented Mar 3, 2026

@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?

@Dcallies
Copy link
Contributor

Dcallies commented Mar 4, 2026

@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.

@aokolish
Copy link
Collaborator

aokolish commented Mar 4, 2026

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:

  1. HMA user updates to the latest image w/this code
  2. The code immediately tries to use the note field
  3. This causes errors because the migrations haven't run yet
  4. Few minutes later, HMA user runs the migrations and things begin working again

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...

  1. Deploy a PR with just the DB migration
  2. Run the migration in prod (and verify nothing breaks)
  3. Deploy subsequent PRs to use the new field

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hma Items related to the hasher-matcher-actioner system

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants