Skip to content

fix(coderd): handle deletes and links for new agent/app audit resources #16670

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

Merged
merged 1 commit into from
Feb 26, 2025

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Feb 24, 2025

These code-paths were overlooked in #16493.

@mafredri mafredri self-assigned this Feb 24, 2025
@mafredri mafredri requested a review from Emyrk February 24, 2025 12:24
if xerrors.Is(err, sql.ErrNoRows) {
return true
}
api.Logger.Error(ctx, "unable to fetch workspace", slog.Error(err))
Copy link
Member Author

Choose a reason for hiding this comment

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

Review: This code-path is confusing, I feel we should return an explicit boolean here, but I simply followed existing convention.

Copy link
Member

Choose a reason for hiding this comment

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

I agree. Do we run a db query for every single audit log row? I was unaware this function existed tbh

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, sure looks like we call it as part of convertAuditLog 😰. I'm surprised the API response isn't slower TBH.

Copy link
Member Author

Choose a reason for hiding this comment

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

I created an issue: #16718

Copy link
Member

@Emyrk Emyrk left a comment

Choose a reason for hiding this comment

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

This follows our existing patterns. I agree both this functions feel a bit off, and feel inefficient too.

Do we really do these functions for every audit log row?!

if xerrors.Is(err, sql.ErrNoRows) {
return true
}
api.Logger.Error(ctx, "unable to fetch workspace", slog.Error(err))
Copy link
Member

Choose a reason for hiding this comment

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

I agree. Do we run a db query for every single audit log row? I was unaware this function existed tbh

@mafredri
Copy link
Member Author

Do we really do these functions for every audit log row?!

Yeah, I was pretty surprised as well. I'm going to merge this but let's create a follow-up issue to track improvements to this code-path.

@mafredri mafredri merged commit b94d2cb into main Feb 26, 2025
34 checks passed
@mafredri mafredri deleted the mafredri/fix-coderd-audit-links branch February 26, 2025 17:16
@github-actions github-actions bot locked and limited conversation to collaborators Feb 26, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants