Skip to content

Migrate to axum#115

Open
lajp wants to merge 35 commits intomainfrom
axum
Open

Migrate to axum#115
lajp wants to merge 35 commits intomainfrom
axum

Conversation

@lajp
Copy link
Copy Markdown
Member

@lajp lajp commented Oct 24, 2025

No description provided.

@lajp lajp requested a review from DrVilepis as a code owner October 24, 2025 07:37
lajp and others added 6 commits October 24, 2025 09:39
also remove all instances of impl IntoResponse in endpoint types
also thank you utoipa
@Eldemarkki
Copy link
Copy Markdown
Member

settings.toml.example is missing the new email fields

Comment thread src/main.rs Outdated
@Eldemarkki
Copy link
Copy Markdown
Member

Secured access mentions should be removed from error.rs and APISPEC.md

@Eldemarkki
Copy link
Copy Markdown
Member

The APISPEC seems to be out of date in general, for example it still has /auth/changepassword endpoint. Maybe the file is not needed now that we have OpenAPI, we could move the descriptions there?

@DrVilepis
Copy link
Copy Markdown
Member

The plan is to completely remove the apispec in favor of openapi. Also I doubt that the apispec is even 50% correct

Comment thread src/api/leaderboards.rs Outdated
DrVilepis
DrVilepis previously approved these changes Dec 17, 2025
Copy link
Copy Markdown
Member

@DrVilepis DrVilepis left a comment

Choose a reason for hiding this comment

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

My preliminary approval now that the pr is starting to be in its final state.

Copy link
Copy Markdown
Member Author

@lajp lajp left a comment

Choose a reason for hiding this comment

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

This looks almost good to go! I mostly complained about unwrap()s but there's some other comments as well. I did not review tests.

Comment thread src/api/auth.rs Outdated
type Error = TimeError;
type Future = Pin<Box<dyn Future<Output = actix_web::Result<Self, Self::Error>>>>;
async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Should this be a Self::Rejection instead of unwrap

Comment thread src/api/auth.rs Outdated
type Error = TimeError;
type Future = Pin<Box<dyn Future<Output = actix_web::Result<Self, Self::Error>>>>;
async fn from_request_parts(parts: &mut Parts, _state: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This probably also shouldn't panic

Comment thread src/api/auth.rs Outdated
type Rejection = TimeError;

async fn from_request_parts(parts: &mut Parts, _: &S) -> Result<Self, Self::Rejection> {
let auth = parts.extensions.get::<Authentication>().cloned().unwrap();
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

don't panic here either

Comment thread src/api/auth.rs

let token = generate_password_reset_token();

let message = Message::builder()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

convert these unwraps to .expect("BUG: <description>") if they are truly infallible

Comment thread src/api/mod.rs Outdated
pub static REGEX: Regex = Regex::new("^[[:word:]]{2,32}$").unwrap();
}
pub static VALID_NAME_REGEX: LazyLock<Regex> =
LazyLock::new(|| Regex::new("^[[:word:]]{2,32}$").unwrap());
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

change this to .expect("BUG: failed to compile name regex") or something like that

Comment thread src/models.rs
}

// Wtf is this
fn project_deserialize<'de, D>(deserializer: D) -> Result<Option<String>, D::Error>
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

should probably be removed :D

Comment thread src/ratelimiter.rs Outdated
let conn_info = req
.extensions()
.get::<ConnectInfo<SocketAddr>>()
.unwrap()
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

.expect("BUG: connection info is always available")

Comment thread src/ratelimiter.rs Outdated
headers.insert(
HeaderName::from_static("ratelimit-limit"),
HeaderValue::from_str(&quota.burst_size().to_string())?,
HeaderValue::from_str(&quota.burst_size().to_string()).unwrap(),
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

please .expect all header value creations

Comment thread src/ratelimiter.rs Outdated
Ok(req.into_response(response.map_into_right_body()))
)
.body(Body::empty())
.unwrap())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

.expect

Comment thread src/ratelimiter.rs Outdated
Ok(Response::builder()
.status(StatusCode::INTERNAL_SERVER_ERROR)
.body(Body::empty())
.unwrap())
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

.expect

Comment thread src/api/auth.rs

if db.get_user_by_name(&data.username).await.is_ok() {
return Err(TimeError::UserExists);
if data.email.as_ref().is_some_and(|e| validate_email(e)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Doesn't this row reject valid emails, and accept invalid emails?

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.

3 participants