question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Environment Placeholders in GitHub Integration Cause Build Failures

See original GitHub issue

We’re attempting to do an initial configuration of our Backstage deployment using the Docker method and including environment placeholders in the app-config.yaml for any sensitive config values.

We’re running into an issue specifically around using the GitHub app created by the backstage CLI, when we replace the values of things like clientSecret clientId and privateKey with the env nomenclature ${GitHubAppPrivateKey} we end up in a config load failure during the following build command:

yarn --cwd packages/backend backstage-cli backend:bundle --build-dependencies

Our app-config.yaml for integrations looks like the following

integrations:
  github:
    - host: github.com
      apps:
        - appId: 111222 #redacted
          webhookUrl: https://smee.io/redactedUrlHere #redacted
          clientId: ${AUTH_GITHUB_CLIENT_ID}
          clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
          webhookSecret: ${WEBHOOK_SECRET}
          privateKey: ${PRIVATE_KEY}

The documentation shows this as a $include with a link to the file, we run into the same error if we $include or put it directly in app-config.

This configuration produces the following errors:

Config should have required property 'clientId' { missingProperty=clientId } at /integrations/github/0/apps/0
Config should have required property 'clientSecret' { missingProperty=clientSecret } at /integrations/github/0/apps/0
Config should have required property 'privateKey' { missingProperty=privateKey } at /integrations/github/0/apps/0
Config should have required property 'webhookSecret' { missingProperty=webhookSecret } at /integrations/github/0/apps/0

If we hardcode the value instead of using the ${ENV_VAR} placeholder, this build command does not fail.

Expected Behavior

We shouldn’t be failing the schema validation when using env var substitutes.

Current Behavior

Schema validation for the GitHub integration is failing, even though the properties are there.

Steps to Reproduce

Use the following in your app-config.yaml:

integrations:
  github:
    - host: github.com
      apps:
        - appId: 111222 #redacted
          webhookUrl: https://smee.io/redactedUrlHere #redacted
          clientId: ${AUTH_GITHUB_CLIENT_ID}
          clientSecret: ${AUTH_GITHUB_CLIENT_SECRET}
          webhookSecret: ${WEBHOOK_SECRET}
          privateKey: ${PRIVATE_KEY}

Attempt the build the Docker image docker build .

Your Environment

  • NodeJS Version (v12): v12.22.1
  • Operating System and Version (e.g. Ubuntu 14.04): Attempted in Win 10, Ubuntu 20.04 (WSL), and in Ubuntu 18.04

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
yafanasievcommented, May 25, 2021

I hit the same issue. When using the multi-stage container build yarn --cwd packages/backend backstage-cli backend:bundle --build-dependencies gets executed, which will not tolerate missing environment variables. This was fixed in a similar issue for app:build command, I assume it should be added for backend:bundle as well.

1reaction
jamesrenaudcommented, May 21, 2021

This may have been a user error in where we were making the environment variables available within the Dockerfile so the variables were indeed undefined at that point in the process.

Seems we’re a bit further along in getting this working, once I’ve got the service stood up again and I’ve confirmed it’s working I’ll post a full follow on in case anyone else runs into this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Build fails with OpenID Client when using Environment variables
Describe the bug When I try to configure the OpenID client with ENV variables in the application.properties, the build fails.
Read more >
Do not use Python's str.format() for expanding placeholders in ...
Placeholders in command environment variables such as CIBW_BEFORE_BUILD and CIBW_BEFORE_TEST are expanded using Python's str.format() :.
Read more >
placeholder can not be work correctly. · Issue #3384 · flyway ...
In this case, Flyway has tried to replace ${tYmdHMS} with an environment variable called tYmdHMS . If the environment variable doesn't exist ...
Read more >
Contexts - GitHub Docs
Contexts are a way to access information about workflow runs, runner environments, jobs, and steps. Each context is an object that contains properties, ......
Read more >
Method to pass environment variables during build vs file ...
For continuous integration purposes, I want to build only once, then deploy that same dist folder to my staging, qa, and prod environments...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found