Variable substitution does not work in Traefik IngressRoutes #3535
-
DescriptionVariable substitution for widget keys, as added in #1043 does not seem to work with Traefik IngressRoutes. Any combination of inputting it in an annotation seems to be broken. However, jameswynn/helm-charts#9 (comment) suggests that this issue might be isolated to Traefik IngressRoutes only, provided the poster only tested with normal Ingresses. Copying that example does not result in a working environment. Only error shown is: "Error attempting k8s environment variable substitution.". It seems that the JSON.parse throws an error when any variable substitution occurs: homepage/src/utils/config/service-helpers.js Line 299 in c6770d2 homepage versionv0.8.13 Installation methodOther (please describe above) ConfigurationNo response Container Logs
Browser LogsNo response TroubleshootingTried and confirmed working:
This correctly works with the widget I was using (replaced with example for the example). All data loads. Tried and confirmed broken:
|
Beta Was this translation helpful? Give feedback.
Replies: 5 comments
-
Thanks for posting a discussion about homepage here on GitHub. Homepage now uses a fancy new AI tool thanks to our friends at Glime, so the answer below is the AI bot's attempt to answer your question. If you feel it's sufficient you can mark the answer and close this post, otherwise feel free to leave it open of course! Thanks for using Homepage! ❤️ Based on the information provided, it seems that you are encountering an issue with environment variable substitution in Kubernetes when using Traefik IngressRoutes with Homepage. The error message "Error attempting k8s environment variable substitution." indicates that the substitution process is failing. Given that you have confirmed the environment variable is correctly set within the container and that direct use of the environment variable in the ConfigMap works as expected, the issue appears to be specific to the annotation-based substitution within Traefik IngressRoutes. The various formats you have tried for the annotations suggest that the issue is not with the syntax of the annotation itself. Instead, it could be related to how Homepage processes these annotations or a limitation within the Traefik IngressRoute's handling of such substitutions. To troubleshoot this issue further, I would recommend the following steps:
If you would like to provide additional information or have specific questions about the steps above, please let me know, and I will do my best to assist you further. This comment was generated by Glime. |
Beta Was this translation helpful? Give feedback.
-
Possible solution might be to replace the separate parsing in try/catch with the following code instead:
This would however remove variable substitution from other fields, which might need the substituteEnvironmentVars() call on their own. Can any maintainer confirm the bug/solution? |
Beta Was this translation helpful? Give feedback.
-
For anyone coming across this, the variable handling does not currently strip whitespace and quotes! So, if you encode your Kubernetes secret wrong, you might end up with whitespace after your api key, which then fails the JSON.stringify() call. If you are creating your Kubernetes secret, remember to do I have submitted a PR to strip these automatically, preventing this failure case: #3642 |
Beta Was this translation helpful? Give feedback.
-
This discussion has been automatically closed because it was marked as answered. See our contributing guidelines for more details. |
Beta Was this translation helpful? Give feedback.
-
This discussion has been automatically locked since there has not been any recent activity after it was closed. Please open a new discussion for related concerns. See our contributing guidelines for more details. |
Beta Was this translation helpful? Give feedback.
For anyone coming across this, the variable handling does not currently strip whitespace and quotes! So, if you encode your Kubernetes secret wrong, you might end up with whitespace after your api key, which then fails the JSON.stringify() call.
If you are creating your Kubernetes secret, remember to do
echo -n "secret" | base64
instead of justecho
.I have submitted a PR to strip these automatically, preventing this failure case: #3642