Skip to content

refactor(v3.1.0): retire Lift dispatch layer, migrate all endpoints to Http4s310#2800

Closed
hongwei1 wants to merge 15 commits into
OpenBankProject:developfrom
hongwei1:refactor/removeV310Lift
Closed

refactor(v3.1.0): retire Lift dispatch layer, migrate all endpoints to Http4s310#2800
hongwei1 wants to merge 15 commits into
OpenBankProject:developfrom
hongwei1:refactor/removeV310Lift

Conversation

@hongwei1
Copy link
Copy Markdown
Contributor

@hongwei1 hongwei1 commented May 20, 2026

Summary

  • Migrates the 2 remaining v3.1.0 Lift-only endpoints (getObpConnectorLoopback, getMessageDocsSwagger) to Http4s310
  • Rewires OBPAPI3_1_0 to use Http4s310.resourceDocs for aggregation; sets routes = Nil (no more Lift dispatch)
  • Stubs APIMethods310.scala down to an empty trait (same pattern as v4.0.0/v5.0.0/v5.1.0/v6.0.0 retirements)
  • Adds case ApiVersion.v3_1_0 => resourceDocs to ResourceDocsAPIMethods skip filter so docs aren't emptied when routes are Nil
  • Adds Implementations3_1_0 re-exports to OBPAPI3_1_0, APIMethods310, OBPAPI5_1_0, and OBPAPI6_0_0 so all downstream nameOf(Implementations3_1_0.xxx) references keep compiling

Test plan

  • Full test suite: 2847 / 2847 passed, 21 ignored, 0 failures (./run_all_tests.sh)
  • v3.1.0 suites green
  • v4.0.0 / v5.0.0 / v5.1.0 / v6.0.0 suites green (cascade through v3.1.0 unchanged)
  • ResourceDocs suites green (doc aggregation includes full v3.1.0 set)
  • Http4s bridge integration suites green

hongwei1 added 15 commits May 20, 2026 11:39
…UT attribute-definition endpoint

Two regressions exposed when the v4.0.0 Lift routes were retired in commit 95db087:

1. answerTransactionRequestChallenge — the Http4s400 implementation was delegating to
   Http4sLiftWebBridge which now returns 404 (no Lift v4 routes registered). Port the
   ~280-line Lift logic to native http4s: supports ChallengeAnswerJson400, maker-checker
   separation, multi-challenge flow (NEXT_CHALLENGE_PENDING), FORWARDED status, and
   the REJECT answer path for SEPA refund reversal.

2. createOrUpdateTransactionRequestAttributeDefinition — the alias in Http4s400 wrongly
   pointed to createOrUpdateTransactionAttributeDefinition (/transaction, Transaction
   category) instead of a dedicated /transaction-request endpoint with TransactionRequest
   category. Add the proper lazy val, ResourceDoc, and allRoutesWithMiddleware wiring.
   Remove the incorrect alias.

3. Http4s400.Implementations4_0_0.implementedInApiVersion — expose as an explicit member
   so ResourceDocsAPIMethods.scala can access it via APIMethods400.Implementations4_0_0.

Test fixes (also exposed by the Lift retirement):
- frozen_type_meta_data: regenerate snapshot to reflect Http4s400 endpoint names
- GetScannedApiVersionsTest: add OBPv4.0.0 to api_enabled_versions so http4s middleware
  does not 404 v4 requests during the version-filter test
- JsonSchemaValidationTest, CounterpartyLimitTest, TransactionRequestTest,
  VRPConsentRequestTest: replace nameOf(Implementations4_0_0.x) with string literals
  (the stub object no longer has an inner Implementations4_0_0 class)
- APIUtilHeavyTest: rewire to use Http4s400.resourceDocs directly with inline prop
  filtering instead of relying on OBPAPI4_0_0's Lift-registered routes
… in Http4s400

All 258 v4.0.0 endpoints have been migrated to Http4s400. This commit removes the
17,042-line Lift implementation body, keeping only a thin compatibility shim:

  object APIMethods400 { val Implementations4_0_0 = Http4s400.Implementations4_0_0 }
  trait APIMethods400  // empty — no Lift routes, no ResourceDocs

The original implementation is preserved as comments (prefixed //) for historical
reference. Callers that previously imported APIMethods400.Implementations4_0_0 still
compile — the re-export provides the same qualified name pointing to the Http4s object.

OBPAPI5_1_0 / OBPAPI6_0_0: the excludeEndpoints lists previously used
nameOf(Implementations4_0_0.xxx) macros which resolved against the Lift inner class.
Replace each with a string literal (the macro just returns the val name as a string)
so the references compile against the empty stub.
…actionRequestAttributeDefinition

v4.0.0 now properly registers the transaction-request attribute definition
endpoint in Http4s400, which was previously missing from the frozen snapshot.
…excludeEndpoints

Replace string literals with nameOf macro calls now that Http4s400.Implementations4_0_0
exposes all the required vals. Add re-export and Http4s400 import to OBPAPI5_1_0 and
OBPAPI6_0_0 so the macro resolves correctly.
…tags

OBPAPI4_0_0: replace string literals in excludeEndpoints with nameOf(OBPAPI3_1_0.Implementations1_2_1.xxx)
and nameOf(OBPAPI3_1_0.Implementations3_1_0.xxx) — resolved via stable singleton path.

Test files: restore nameOf(Implementations4_0_0.createTransactionRequestCounterparty)
in CounterpartyLimitTest, TransactionRequestTest, VRPConsentRequestTest.
…o Http4s310

getObpConnectorLoopback: returns 400+NotImplemented (mirrors Lift throw).
getMessageDocsSwagger: stub val + ResourceDoc only — real routing handled by
Http4sResourceDocs (wildcard /obp/*/message-docs/{CONNECTOR}/swagger2.0,
wired into Http4sApp before v310Routes). Both vals are required so nameOf
compiles in downstream test files after OBPAPI3_1_0 is migrated.
All 100 v3.1.0 endpoints now live in Http4s310 (wired into Http4sApp).
OBPAPI3_1_0 is retained only for resource-doc aggregation:
- allResourceDocs = collectResourceDocs(OBPAPI3_0_0.allResourceDocs, Http4s310.resourceDocs)
- routes = Nil (Lift dispatch retired)
- Re-exports Implementations3_1_0/1_2_1/2_2_0 so callers keep compiling

ResourceDocsAPIMethods: add v3.1.0 to the http4s skip filter so the
route-class filter does not empty the doc set when routes=Nil.
…orts

APIMethods310: replace 6065-line Lift implementation with empty trait stub.
object APIMethods310 re-exports Implementations3_1_0 → Http4s310 so
SystemViewsTests (which imports APIMethods310.Implementations3_1_0) compiles.

OBPAPI5_1_0/OBPAPI6_0_0: add Implementations3_1_0 = Http4s310.Implementations3_1_0
re-export + Http4s310 import so nameOf(Implementations3_1_0.xxx) in their
excludeEndpoints continues to compile after the APIMethods310 stub.
Three bugs introduced by the v3.1.0 Lift retirement:

1. NPE in Http4s121.wrappedRoutesV121Services: Scala initialised the val
   to null before Http4s121.Implementations1_2_1 was ready, so every
   request reaching the v1.3.0→v1.2.1 bridge threw NullPointerException
   (no Correlation-Id, status 500). Fixed by making it lazy val.

2. FrozenClassTest (STABLE API contract): the migration merged
   createConsentSms/createConsentEmail/createConsentImplicit into a single
   createConsent endpoint, violating the frozen partialFunctionName set.
   Restored the three original endpoint names as separate ResourceDocs
   pointing to the same handler.

3. SystemViewsTests: the `if viewIdStr.nonEmpty` guards on getSystemView,
   deleteSystemView, and updateSystemView were added to fall through to the
   Lift bridge, which no longer exists for v3.1.0. Removing the guards
   lets the middleware return 401/403 for empty-viewId requests, matching
   the test expectations.
…est, loopback auth

- Http4sSupport: withUser/withUserDelete/etc now throw RuntimeException(AuthenticatedUserIsRequired)
  so ErrorResponseConverter resolves to 401 via getCodeByOBPPrefix rather than 500
- ResourceDocMiddleware: case None path now runs best-effort anonymousAccess so cc.user is
  populated from request credentials even when no ResourceDoc matches (empty segment bypass)
- Http4s310 createConsent: use withUserAndBodyCreated (no bank from CC needed) so SCA method
  check (booleanToFuture 400) fires before bank validation is attempted for invalid SCA methods
- Http4s310 getObpConnectorLoopback: change description to userAuthenticationMessage(false)
  so AuthenticatedUserIsRequired is not auto-added to error list; endpoint is anonymous (returns
  400 NotImplemented unconditionally)
- CardAttributeTest: use partialFunctionName==nameOf(...) instead of partialFunction==... which
  always returns null for http4s endpoints
…tch v5.1.0/v6.0.0 cross-refs

- OBPAPI3_0_0: drop all APIMethods mixin chain (130→300 + CustomAPIMethods300), set
  routes=Nil, switch allResourceDocs to collectResourceDocs(OBPAPI2_2_0, Http4s300),
  add re-export val Implementations3_0_0 = Http4s300.Implementations3_0_0 (18 test
  files reference it via nameOf(Implementations3_0_0.<endpoint>))
- OBPAPI5_1_0 / OBPAPI6_0_0: drop APIMethods300 + CustomAPIMethods300 mixins and
  imports; add import Http4s300; add re-export val Implementations3_0_0 =
  Http4s300.Implementations3_0_0 so nameOf(Implementations3_0_0.getUserByUsername)
  in excludeEndpoints keeps compiling
- ResourceDocsAPIMethods: add v3_0_0 to http4s skip filter (routes=Nil would drop
  all docs without this bypass)

All v3.0.0 endpoints are served by Http4s300 (47 endpoints, 1:1 coverage with
APIMethods300). APIMethods300 stub follows in the next commit.
Drop the 2526-line Lift implementation body from APIMethods300.scala —
all v3.0.0 endpoints are served by Http4s300. The empty trait stub is
retained so existing `with APIMethods300` mixin sites keep compiling.
object APIMethods300 re-exports Implementations3_0_0 = Http4s300.Implementations3_0_0
so v3_1_0/ConsentTest and v5_1_0/ConsentObpTest continue to compile.

CustomAPIMethods300 is retired to a no-op stub — its only endpoint was
null and its resourceDocs buffer was empty (nothing was ever served).
Three v4.0.0 tests (AuthenticationTypeValidationTest, ForceErrorValidationTest,
JsonSchemaValidationTest) import OBPAPI3_0_0.Implementations2_2_0 for
nameOf(...) Tag construction. The v3.0.0 retirement removed the
APIMethods220 mixin that previously provided this val.

Add re-export val Implementations2_2_0 = Http4s220.Implementations2_2_0
so these tests keep compiling without modification.
@sonarqubecloud
Copy link
Copy Markdown

@hongwei1 hongwei1 closed this May 20, 2026
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