Skip to content

Conversation

@P4uline
Copy link
Contributor

@P4uline P4uline commented Dec 30, 2025

https://issues.rudder.io/issues/28040

  • Migrate the class CheckRudderGlobalParam from lift-json to zio-json
  • Change the value type from the lift-json AST to the zio-json AST
  • Rename the class to CheckRudderGlobalProperties, global properties is actually the proper business term.
  • deprecate old lift-json method fromJsonValue with a nowarn the remaining calls
  • Some other minor fixes

@P4uline P4uline changed the title Fixes #28040: Migrate CheckRudderGlobalParam to zio-jon in rudder-webapp Fixes #28040: Migrate CheckRudderGlobalParam to zio-json in rudder-webapp Dec 30, 2025
@P4uline
Copy link
Contributor Author

P4uline commented Dec 30, 2025

PR updated with a new commit

@P4uline
Copy link
Contributor Author

P4uline commented Dec 30, 2025

PR rebased

@P4uline P4uline force-pushed the arch_28040/migrate_checkrudderglobalparam_to_zio_jon_in_rudder_webapp branch from 257ee9c to 10dd842 Compare December 30, 2025 17:46
@P4uline
Copy link
Contributor Author

P4uline commented Dec 30, 2025

PR updated with a new commit

@P4uline
Copy link
Contributor Author

P4uline commented Dec 30, 2025

PR rebased

@P4uline P4uline force-pushed the arch_28040/migrate_checkrudderglobalparam_to_zio_jon_in_rudder_webapp branch from 2660d2c to cb5cc0f Compare December 30, 2025 18:01
/**
* Parse a JSON JValue to ConfigValue. It always succeeds.
*/
@Deprecated(since = "8.0", forRemoval = true)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure actually if the migration to zio-json started on version 8.0...

Copy link
Contributor

Choose a reason for hiding this comment

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

The migration started a long time ago (7.0.0 IIRC)
Why wouldn't it be 9.1 ?
This would be removed when we migrate the whole Properties.scala, that I hope is before the 9.1 release...


// lift json need that to be topevel
// TODO: handle the following TODO
// TODO: add Option[String] revision in API
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@fanf I would like to create a redmine ticket to handle to delete the TODO

// TODO: add Option[String] revision in API

Just need a bit of context

@clarktsiory clarktsiory self-requested a review December 31, 2025 08:53
Copy link
Contributor

@clarktsiory clarktsiory left a comment

Choose a reason for hiding this comment

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

I only have a few suggestions, I'm open to discuss these few aspects !

Comment on lines +81 to +95
case Right(Json.Arr(list)) =>
ZIO.foreach(list)(v => {
v.as[GlobalPropertiesJson] match {
case Left(error) =>
Unexpected(
s"An unexpected error occurred while decoding json global properties $v as $GlobalPropertiesJson: $error"
).fail
case Right(value) => IOResult.attempt(value.toGlobalParam)
}

})
case _ =>
Inconsistency(
s"Resources `$resource` must contain an array of json object with keys name, description, value."
).fail
Copy link
Contributor

Choose a reason for hiding this comment

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

With our error-handling utils (in the ZioCommons file, e.g. EitherToIoResult#toIO), we have multiple ways to have a fluent syntax, instead of pattern matching (which at some point could hurt readability).
Here it could be something like :

value.map(_.asArray)
  .toIO
  .notOptional(s"Resources `$resource` must contain an array of json object with keys name, description, value.")
  .flatMap(arr =>
    ZIO.foreach(...)(/* can also be fluent  */)
  )

}
object GlobalPropertiesJson {
implicit val decoder: JsonDecoder[GlobalPropertiesJson] = DeriveJsonDecoder.gen[GlobalPropertiesJson]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

now this is more verbose than derives JsonDecoder, I would happier with the derives syntax since the case class is already a JSON one 😄

/**
* Parse a JSON JValue to ConfigValue. It always succeeds.
*/
@Deprecated(since = "8.0", forRemoval = true)
Copy link
Contributor

Choose a reason for hiding this comment

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

The migration started a long time ago (7.0.0 IIRC)
Why wouldn't it be 9.1 ?
This would be removed when we migrate the whole Properties.scala, that I hope is before the 9.1 release...

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.

2 participants