Skip to content

Audit of warn! and error! - #5640

Open
JasonAtClockwork wants to merge 5 commits into
masterfrom
jlarabie/audit-logs
Open

Audit of warn! and error!#5640
JasonAtClockwork wants to merge 5 commits into
masterfrom
jlarabie/audit-logs

Conversation

@JasonAtClockwork

Copy link
Copy Markdown
Contributor

Description of Changes

Reviewed all warn! and error! lines for host side issues to get ready for alerting.

API and ABI breaking changes

No breaking changes.

Expected complexity level and risk

1 - Only changes to logging

Testing

  • Ran cargo test against impacted crates

Comment thread crates/client-api/src/routes/database.rs
Comment thread crates/client-api/src/routes/subscribe.rs
Comment on lines 166 to 169
.map_err(|e| {
// TODO: Review log level after user SQL errors can be distinguished from internal database failures.
log::warn!("{e}");
(StatusCode::BAD_REQUEST, e.to_string())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as other areas we might want to split this up so we can use error! if there is a database failure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you create a follow-up ticket?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Follow-up created: #5690

I did go down the rabbit-hole of all the possible issues and decided to make the follow-up simple instead of declaring all possible areas of concern.

Comment on lines +642 to 645
// TODO: Review each caller and split this helper by the appropriate log severity.
pub fn log_and_500(e: impl std::fmt::Display) -> ErrorResponse {
log::error!("internal error: {e:#}");
(StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#}")).into()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seems to be very broadly used which makes it hard to know if it should be reduced from error! my gut reaction is to change it to warn! and slowly clean up it's use?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change to warn for now, and any place you're already editing that has a log_and_500 directly next to its own more specific log line, remove the log_and_500 call and replace with directly returning the error response. You may want to move the error response into a new helper function.

Comment on lines +216 to 217
// TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers.
log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one I'm not 100% sure if we need to split up or count everything as warn!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have no clue. At this stage I'm unconcerned.

Comment on lines +682 to 685
// TODO: Review log level after migration/user errors can be distinguished from internal database failures.
log::warn!("Database update failed: {} @ {}", e, stdb.database_identity());
system_logger.warn(&format!("Database update failed: {e}"));
let (_, tx_metrics, reducer) = stdb.rollback_mut_tx(tx);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Another spot where it looks like real failures can be mixed in with user issues.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Make a follow-up?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added a follow-up: #5691

Comment on lines +1403 to 1405
// TODO: Review log level after guest view errors can be distinguished from materialization failures.
log::error!("Error materializing view `{view_name}`: {err:?}");
ViewOutcome::Failed(format!("Error materializing view `{view_name}`: {err}"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This one looked similar as above but I'm not certain if it's true that it can be mixed here.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Another follow-up ticket? And, can @joshua-spacetime weigh in as to whether user errors can happen here, which I assume would be if a view function panics.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes if a view function panics. Primary key violations too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Ok, then we should drop this to warn.

@JasonAtClockwork
JasonAtClockwork marked this pull request as ready for review July 31, 2026 23:19
@bfops

bfops commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

FYI #5320 is about to merge which tweaks some logs as well

Signed-off-by: Jason Larabie <jason@clockworklabs.io>
Comment thread crates/client-api/src/routes/database.rs
Comment thread crates/client-api/src/routes/subscribe.rs
Comment on lines 166 to 169
.map_err(|e| {
// TODO: Review log level after user SQL errors can be distinguished from internal database failures.
log::warn!("{e}");
(StatusCode::BAD_REQUEST, e.to_string())

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you create a follow-up ticket?

Comment on lines +642 to 645
// TODO: Review each caller and split this helper by the appropriate log severity.
pub fn log_and_500(e: impl std::fmt::Display) -> ErrorResponse {
log::error!("internal error: {e:#}");
(StatusCode::INTERNAL_SERVER_ERROR, format!("{e:#}")).into()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please change to warn for now, and any place you're already editing that has a log_and_500 directly next to its own more specific log line, remove the log_and_500 call and replace with directly returning the error response. You may want to move the error response into a new helper function.

Comment on lines +216 to 217
// TODO: Review log level after configured issuers can be distinguished from arbitrary token issuers.
log::warn!("Error fetching public key for issuer {raw_issuer}: {e:?}");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I have no clue. At this stage I'm unconcerned.

Some(ptr) => self.delete(ST_CLIENT_ID, ptr).map(drop)?,
_ => {
log::error!(
log::warn!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@joshua-spacetime how can this (and the other previously error! logs in this file) happen, and how bad is it?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not bad. They only happen if the row is missing, which just means it was cleaned up previously. They don't need to be error logs.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

How about we drop to info, then?

}
Err(e) => {
// TODO: Review log level after retryable cleanup errors can be distinguished from internal database failures.
log::error!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What user errors can get mixed in here?

let res = self
.maybe_take_snapshot(database_state.as_ref())
.await
// TODO: Review log level after lifecycle errors can be distinguished from snapshot creation failures.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please create a follow-up ticket.

Comment on lines +139 to 140
// TODO: Review log level after client SQL errors can be distinguished from internal database failures.
log::error!("PG: Error for database {database}: {err}");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Downgrade to warn, at least until the TODO is done. Please make a follow-up ticket, but mark it P3.

Comment on lines +275 to 276
// TODO: Do not log the supplied password/token; then classify credential errors separately from provider failures.
log::error!(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please downgrade to warn, and make a P3 follow-up, as above.

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.

4 participants