Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TECH] Ajouter une valeur par défaut pour LOG_ENABLED #8845

Merged
merged 1 commit into from
May 14, 2024

Conversation

dlahaye
Copy link
Contributor

@dlahaye dlahaye commented May 6, 2024

🦄 Problème

Lors de cette PR, une régression a été introduite côté API dans la configuration des variables d'environnements. Ainsi, en local, nous n'avions plus de logs pour l'API, car la variable par défaut LOG_ENABLED était commentée dans le sample.env (et donc dans les .env locaux).

🤖 Proposition

Par mesure de sécurité, nous avons passé LOG_ENABLED en required dans le fichier api/lib/infrastructure/validate-environment-variables.js et nous l'avons dé-commenté du sample.env

🌈 Remarques

Le fichier config.js n'est pas testé et on constate qu'il peut y avoir des régressions.
Peut-être faudrait-il tester au cas par cas lorsqu'on trouve une régression (par exemple en commençant par le cas présent) ?
Cela peut être un sujet d'aprèm tech.

💯 Pour tester

  1. Récupérer la branche
  2. Commenter la variable LOG_ENABLED dans le .env
  3. Lancer l'api en local
  4. S'assurer que le terminal renvoi une erreur car la variable est requise
  5. Dé-commenter la variable et lui assigner true
  6. Relancer l'api
  7. S'assurer que les logs apparaissent

@pix-bot-github
Copy link

Une fois les applications déployées, elles seront accessibles via les liens suivants :

Les variables d'environnement seront accessibles via les liens suivants :

@Steph0 Steph0 self-requested a review May 6, 2024 12:52
@Steph0
Copy link
Contributor

Steph0 commented May 6, 2024

3 tests func, 2 OK, 1 KO ✔️ ✔️ 🎌

LOG_ENABLED = false
image

LOG_ENABLED = true
image

Suppression env LOG_ENABLED 🎌
image

Copy link
Contributor

@Steph0 Steph0 left a comment

Choose a reason for hiding this comment

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

Je propose le changement suite au KO test func (voir commentaires)

api/src/shared/config.js Outdated Show resolved Hide resolved
@@ -21,7 +21,7 @@ const schema = Joi.object({
DOMAIN_PIX_ORGA: Joi.string().optional(),
LCMS_API_KEY: Joi.string().required(),
LCMS_API_URL: Joi.string().uri().required(),
LOG_ENABLED: Joi.string().optional().valid('true', 'false'),
LOG_ENABLED: Joi.string().required().valid('true', 'false'),
Copy link
Member

Choose a reason for hiding this comment

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

Il faudra bien communiquer ce changement pour éviter des incompréhensions ! (surtout en cette forte période d'absence ne pas hésitez à en reparler)

@dlahaye dlahaye force-pushed the fix-logs-in-api-config-js branch from da8046d to 687aa9b Compare May 7, 2024 11:45
@dlahaye dlahaye requested a review from yannbertrand May 7, 2024 11:47
@Steph0 Steph0 force-pushed the fix-logs-in-api-config-js branch from 687aa9b to 434ec6c Compare May 7, 2024 12:43
@dlahaye dlahaye force-pushed the fix-logs-in-api-config-js branch from 434ec6c to 906ebf0 Compare May 7, 2024 13:01
@@ -340,7 +340,7 @@ LCMS_API_URL=https://lcms.minimal.pix.fr/api
# presence: optional
# type: Boolean
# default: `true`
# LOG_ENABLED=true
LOG_ENABLED=true
Copy link
Contributor

Choose a reason for hiding this comment

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

Alignement de la propriété faite, mais on a un gros doute sur le fait que ce fichier soit utilisé par quoi / qui que ce soit (en tout cas pas par les tests e2e)

api/sample.env Outdated Show resolved Hide resolved
@dlahaye dlahaye force-pushed the fix-logs-in-api-config-js branch 2 times, most recently from ddf7b7f to b5263ee Compare May 10, 2024 12:12
@yannbertrand
Copy link
Member

Il manque quelque chose pour merger ?

@dlahaye
Copy link
Contributor Author

dlahaye commented May 14, 2024

Il manque quelque chose pour merger ?

Non je ne pense pas. @Steph0 ?

@dlahaye dlahaye force-pushed the fix-logs-in-api-config-js branch from b5263ee to a8f0cfc Compare May 14, 2024 09:28
@dlahaye
Copy link
Contributor Author

dlahaye commented May 14, 2024

@yannbertrand vu avec @Steph0 LGTM 🚀

@pix-service-auto-merge pix-service-auto-merge merged commit 12569bf into dev May 14, 2024
5 of 7 checks passed
@pix-service-auto-merge pix-service-auto-merge deleted the fix-logs-in-api-config-js branch May 14, 2024 10:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-team Toutes les équipes de dev Func Review OK PO validated functionally the PR 🚀 Ready to Merge Tech Review OK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants