Skip to content

fix: resolve 330+ backend compilation errors#149

Open
GazzyLee wants to merge 10 commits into
Arenax-gaming:mainfrom
GazzyLee:fix/backend-compilation-errors
Open

fix: resolve 330+ backend compilation errors#149
GazzyLee wants to merge 10 commits into
Arenax-gaming:mainfrom
GazzyLee:fix/backend-compilation-errors

Conversation

@GazzyLee
Copy link
Copy Markdown

@GazzyLee GazzyLee commented Mar 25, 2026

Summary

Resolves 330+ backend compilation errors by converting all SQLx compile-time macros to runtime query equivalents, fixing type conflicts, updating deprecated Redis APIs, and resolving Rust 2024 compatibility issues — verified with cargo build passing locally.

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Refactor / cleanup
  • Docs / config only

Related issues

Closes #128

Changes

  • SQLx macro → runtime query conversion (7 service files): Replaced all sqlx::query!() / sqlx::query_as!() compile-time macros with sqlx::query() / sqlx::query_as::<_, T>() using .bind() chains — eliminates the need for DATABASE_URL at compile time
    • auth_service.rs — full rewrite (~25 queries)
    • match_service.rs — recreated from scratch (~40 queries: matchmaking, ELO, scores, disputes, leaderboard)
    • tournament_service.rs — ~30 macros converted
    • governance_service.rs — 5 macros converted
    • match_authority_service.rs — 10+ macros converted
    • wallet_service.rs — 12 macros converted
    • stellar_service.rs — 4+ macros converted
  • Redis never-type fallback (Rust 2024 compat): Added explicit ::<()> type annotations to all Redis calls (query_async, set_ex, del, sadd, expire, incr) in jwt_service.rs and device_service.rs
  • DbPool type conflicts: Removed duplicate pub type DbPool = Arc<PgPool> in wallet_service.rs and stellar_service.rs; unified on crate::db::DbPool
  • Redis 0.27 breaking change: Replaced deprecated get_async_connection() with get_multiplexed_async_connection() in device_service.rs (3 call sites)
  • Missing derives: Added #[derive(Clone)] to JwtService, sqlx::Type to PaymentProvider enum
  • Type mismatches: Fixed Option<i64> vs i64 comparison and i32/usize mismatch in tournament_service.rs
  • Validator incompatibility: Removed #[validate(range)] from Decimal fields (validator crate doesn't support rust_decimal::Decimal)
  • Visibility fixes: Made validate_transition pub(crate) for test access, made CreateNotificationRequest pub
  • Missing module declarations: Added pub mod auth_service in service/mod.rs, pub mod auth_handler in http/mod.rs, mod models in main.rs, test modules in auth/mod.rs and service/mod.rs
  • Option<String> Display fix: Used .as_deref().unwrap_or("none") in auth_handler.rs tracing macro
  • Test fixes: Replaced DbPool::default() with PgPoolOptions::connect_lazy() in test helpers
  • Dead code cleanup: Deleted auth_service_updated.rs and match_model.rs
  • CI: Added backend job to .github/workflows/ci.yml with SQLX_OFFLINE=true (fmt check, build, clippy, test)

Testing

  • Unit tests pass (cargo test / npm test)
  • Contracts tests pass (cargo test in contracts/)
  • Manually tested locally
  • Migration tested against a fresh DB

cargo build --all-targets passes with exit code 0. cargo clippy --all-targets passes with warnings only (all pre-existing dead code, no new warnings). Tests require a running Postgres + Redis instance.

Checklist

  • Code follows project conventions
  • No secrets or PII committed
  • Migrations are reversible (.down.sql exists)
  • Contract changes are backward-compatible or versioned
  • CI passes

@GazzyLee GazzyLee requested a review from anonfedora as a code owner March 25, 2026 22:40
@vercel
Copy link
Copy Markdown

vercel Bot commented Mar 25, 2026

@Gazzy-Lee is attempting to deploy a commit to the paul joseph's projects Team on Vercel.

A member of the Team first needs to authorize it.

@anonfedora
Copy link
Copy Markdown
Contributor

CI isn't passing

@drips-wave
Copy link
Copy Markdown

drips-wave Bot commented Mar 26, 2026

@GazzyLee Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@anonfedora
Copy link
Copy Markdown
Contributor

fix merge conflicts, please

@anonfedora
Copy link
Copy Markdown
Contributor

We still have merge conflicts @GazzyLee

@GazzyLee GazzyLee force-pushed the fix/backend-compilation-errors branch from 1875523 to 51b80be Compare March 29, 2026 18:56
- Add explicit type annotations to Redis calls to fix never-type
  fallback errors (Rust 2024 compat): query_async::<()>, set_ex::<_,_,()>,
  del::<_,()>, sadd::<_,_,()>, expire::<_,()>, incr::<_,_,()>
  in jwt_service.rs and device_service.rs
- Add #[derive(Clone)] to JwtService (required by AuthService derive)
- Fix Option<String> Display in auth_handler.rs info! macro
- Fix Option<i64> vs i64 comparison in tournament_service.rs
- Fix i32/usize type mismatch in tournament bracket generation
- Remove #[validate(range)] from Decimal fields (validator crate
  doesn't support rust_decimal::Decimal for ValidateRange)
- Make validate_transition pub(crate) for test access
- Make CreateNotificationRequest pub (private type in public API error)
- Run cargo fmt --all to fix formatting across 7 files
- Fix ~143 clippy warnings via cargo clippy --fix (redundant closures, unused imports/vars)
- Add #[allow(dead_code)] to crate roots (WIP services not yet wired to routes)
- Add #[allow(dead_code)] to deserialization structs in soroban_service/stellar_service
- Convert DeviceType ToString impl to Display (clippy::to_string_trait_impl)
- Factor complex tuple type into type alias in device_service
- Fix always-true assertions in tests
- Add #[allow(clippy::too_many_arguments)] to record_transaction
- Remove unused sqlx::Row import from match_authority_service

All three CI checks now pass locally:
  cargo fmt --all -- --check (exit 0)
  cargo clippy --all-targets -- -D warnings (exit 0)
  cargo build --all-targets (exit 0)
- Convert sqlx::query!/query_as! macros to runtime queries (no .sqlx offline cache)
- Fix Claims.user_id -> Claims.sub with Uuid::parse_str
- Fix PgRow field access to use try_get()
- Fix Option<i32> unwrapping for ELO calculations
- Fix double-Option on average_wait_time
- Add local ApiResponse in reputation_handler
- Add leave_queue() public method to MatchmakerService
- Fix moved value and Redis never-type fallback in matchmaker
@GazzyLee GazzyLee force-pushed the fix/backend-compilation-errors branch from 6d0958e to e4ec44e Compare March 31, 2026 14:59
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.

Resolve 330+ Backend Compilation Errors & Establish CI/CD Pipeline

3 participants