Skip to content

Comments

1420 runbrokerquery management command is broken#1422

Merged
jchate6 merged 5 commits intodevfrom
1420-runbrokerquery-management-command-is-broken
Feb 24, 2026
Merged

1420 runbrokerquery management command is broken#1422
jchate6 merged 5 commits intodevfrom
1420-runbrokerquery-management-command-is-broken

Conversation

@jchate6
Copy link
Contributor

@jchate6 jchate6 commented Feb 24, 2026

This updates the runbrokerquery management command to validate unique targets, use the modern returns form to_target, and run post save hooks even for new targets.

Because I'm bad at git, this also includes updates to the Pillow and Cryptography dependencies.

@jchate6 jchate6 requested a review from phycodurus February 24, 2026 18:25
@jchate6 jchate6 requested a review from griffin-h February 24, 2026 18:28
@jchate6 jchate6 moved this to Needs Review in TOM Toolkit Feb 24, 2026
@jchate6 jchate6 added this to the Griffin's PRs and Issues milestone Feb 24, 2026
name.full_clean()
name.save()

if not created:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Does anybody know why we don't run post_save_hooks on new targets?
I'm not eager to tear down a Chesterton Fence...

Copy link
Contributor

Choose a reason for hiding this comment

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

As long as this stays in, I believe this also closes #661

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was added in 2019 v1.2.0 with the "initial" version of post save hooks. (technically this was added in a fix that reverted to an older version of post_save_hooks but the result is the same)
I see no discussion or explanation for why it was done this way.

@griffin-h
Copy link
Contributor

Just to make sure I'm understanding correctly, if there is a match between a new alert and an existing target, this will just write a warning to the log and move on to the next alert, correct? Eventually we would want it to add info from the new alert to the existing target, but that can be a separate issue.

@jchate6
Copy link
Contributor Author

jchate6 commented Feb 24, 2026

Just to make sure I'm understanding correctly, if there is a match between a new alert and an existing target, this will just write a warning to the log and move on to the next alert, correct? Eventually we would want it to add info from the new alert to the existing target, but that can be a separate issue.

This is correct.

We have a branch in development right now for data services that updates Reduced Datums for existing targets, and an issue that will allow you to update target model information, thought this is a more interactive process than could probably be done from a management command.

@jchate6 jchate6 linked an issue Feb 24, 2026 that may be closed by this pull request
Copy link
Contributor

@griffin-h griffin-h left a comment

Choose a reason for hiding this comment

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

I can confirm that this runs as expected now! I haven't had a chance to test the validate_unique portion yet, but I consider that just a bonus for now.

@griffin-h
Copy link
Contributor

griffin-h commented Feb 24, 2026

I haven't had a chance to test the validate_unique portion yet, but I consider that just a bonus for now.

Actually I take it back, I realized I could just run the management command again and get a bunch of duplicates to test. This is the warning message that gets printed:
WARNING: {'name': ['Target with this Name already exists.']}
It would be nice if we could get the names of both the new and existing targets in here, but otherwise this works as expected too.

@jchate6 jchate6 merged commit 951ff38 into dev Feb 24, 2026
26 checks passed
@github-project-automation github-project-automation bot moved this from Needs Review to Merged (to dev) in TOM Toolkit Feb 24, 2026
@jchate6 jchate6 deleted the 1420-runbrokerquery-management-command-is-broken branch February 24, 2026 19:34
@jchate6 jchate6 moved this from Merged (to dev) to Released in TOM Toolkit Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Released

Development

Successfully merging this pull request may close these issues.

runbrokerquery management command is broken Cryptography and pillow vulnerabilities Run target_post_save hook when importing targets from file

3 participants