Skip to content

Fixes for Issues with Beacon Tasks #1928

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

RafBishopFox
Copy link
Collaborator

I received a report that beacon tasks could not be cancelled because of a database issue. It turns out that listing beacon tasks was not possible because of a related root issue.

When cancelling a beacon task, saving the object after updating the state field caused GORM to write the timestamp for the created_at column as an integer. When the created_at column was read back in, GORM was trying to convert the integer value into a time.Time object which it did not like. Since created_at is only modified at creation time, there is no need to update the entire object using Save(). This PR updates only the State field when a task is cancelled which avoids messing with the created_at field.

When listing beacon tasks, something similar was happening. When we were selecting tasks using .Select() to avoid grabbing the request and response columns, that bypasses GORM's field to column mapping, and GORM tries to cast the timestamp into a time.Time object unsuccessfully. This PR grabs the entire object and instructs the ToProtobuf function to omit the Request and Response fields.

While I was going down these rabbit holes, I noticed that if you cancelled a task and specified its ID (tasks cancel [ID]), the server panicked. It looks like the Request column was pulled and when passed back to the server, it panicked. This PR nils those fields before sending the task to the server.

@RafBishopFox RafBishopFox requested a review from a team as a code owner April 11, 2025 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant