Configuration via environment variables is broken

Created on 8 July 2024, 2 months ago
Updated 2 September 2024, 5 days ago

Problem/Motivation

I've noticed that there were no error report flowing in when they were (unfortunately ) expected.

Tested on Raven: Sentry Integration 6.0.3 ; Drupal 10.2.6 .

Steps to reproduce

Configure the module using the following environment variables:

  • SENTRY_ENVIRONMENT
  • SENTRY_DSN
  • SENTRY_RELEASE

Expected result

  • Module functionality is fully functional: PHP and JS errors are reported to the Sentry.
  • Drupal status report confirms the module is configured correctly.

Expected result

  • Module functionality is fully functional: PHP and JS errors are reported to the Sentry - fail
  • Drupal status report confirms the module is configured correctly - fail:
    • Sentry DSN - NULL Sentry client key is not configured. No events will be sent to Sentry.
    • Sentry environment - prod
    • Sentry release is not present on the page

Proposed resolution

Fix the Drupal integration code or update documentation mentioning environment variables.

Remaining tasks

User interface changes

API changes

Data model changes

πŸ› Bug report
Status

Closed: cannot reproduce

Version

6.0

Component

Code

Created by

πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @RoSk0
  • Status changed to Postponed: needs info 2 months ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    @RoSk0 it works for me. Did you verify that $_SERVER['SENTRY_DSN'], etc. are in fact set in your environment?

    Are you using the symfony/dotenv or vlucas/phpdotenv package to manage your environment variables, or custom code? If custom code, make sure you are in fact setting $_SERVER['SENTRY_DSN'], etc.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    A command-line check to verify this is working:

    SENTRY_ENVIRONMENT=mic-check ./vendor/bin/drush status-report | grep Sentry\ environment

    prints:

    Sentry environment Info mic-check
  • πŸ‡³πŸ‡ΏNew Zealand RoSk0 Wellington

    I've done a bit more digging and this is what I observe:

    www-data@31b009f0b41c:~$ env|grep ^SENTRY
    SENTRY_ENVIRONMENT=development
    SENTRY_DSN=******************************************
    SENTRY_RELEASE=test-local-release
    www-data@31b009f0b41c:~$ drush status-report | grep 'Sentry release'
      Sentry release                     Info       test-local-release  
    

    Drupal status report still says

    • Sentry DSN - NULL Sentry client key is not configured. No events will be sent to Sentry.
    • Sentry environment - prod

    I've set $settings['sa_core_2023_004_phpinfo_flags'] to INFO_ALL and now can clearly see the the problem comes from the Apache - Environment of phpinfo() output has SENTRY_DSN environment variable as well as $_ENV, but not $_SERVER.

    At the same time, getenv('SENTRY_DSN') returns the correct value when executed via Apache.

    It's clearly not a bug of this module, but rather a standard behaviour of the webserver in question.

    Apache documentation mentions that on the first lines here https://httpd.apache.org/docs/current/env.html :

    First, there are the environment variables controlled by the underlying operating system. These are set before the server starts. They can be used in expansions in configuration files, and can optionally be passed to CGI scripts and SSI using the PassEnv directive.

    I think it would be good to add some notes to the documentation to mention this Apache behaviour, but I will leave it to your discretion.

  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    Documenting how environment variables work feels a bit out of scope, since it changes so much depending on the environment, but if someone wants to contribute a documentation merge request I can look at it.

  • Status changed to Closed: cannot reproduce 5 days ago
  • πŸ‡ΊπŸ‡ΈUnited States mfb San Francisco

    Closing for now but feel free to re-open if anyone wants to suggest documentation improvements

Production build 0.71.5 2024