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

Site name that contains empty spaces is incorrectly displayed in browser tab #61

Closed
Tracked by #505 ...
regisb opened this issue Oct 3, 2022 · 11 comments · Fixed by #62
Closed
Tracked by #505 ...

Site name that contains empty spaces is incorrectly displayed in browser tab #61

regisb opened this issue Oct 3, 2022 · 11 comments · Fixed by #62
Assignees
Labels
bug Something isn't working
Milestone

Comments

@regisb
Copy link
Contributor

regisb commented Oct 3, 2022

This is how a site name that includes white spaces appears in my browser tab:

multi line site name

This bug is almost certainly caused by this recent change: #59

@ghassanmas I should have tested your change more thoroughly. Can you please suggest a fix?

@regisb regisb added the bug Something isn't working label Oct 3, 2022
@ghassanmas
Copy link
Member

@regisb, Did you build the mfe image on a MAC/Zsh OS?

@regisb
Copy link
Contributor Author

regisb commented Oct 3, 2022

Nope, a regular x64 Linux.

@ghassanmas
Copy link
Member

ghassanmas commented Oct 3, 2022 via email

@regisb
Copy link
Contributor Author

regisb commented Oct 3, 2022

You caught me! I'm usually the one asking for this kind of details :-p

$ tutor --version
tutor, version 14.0.5
$ tutor plugins list | grep mfe
mfe                             14.0.1
$ tutor dev start -d

The issue is observed in dev mode, in particular in the account MFE: http://apps.local.overhang.io:1997/account

Indeed, I expect that the issue will not occur in "local" mode because of an implementation quirk which I just realised: the values in mfe/build/mfe/env/ are parsed by bash in production:

RUN bash -c "set -a && source /openedx/env/production && source /openedx/env/production.override && npm run build"

But in development they are parsed by docker-compose:

env_files:
    - ../plugins/mfe/build/mfe/env/production
    - ../plugins/mfe/build/mfe/env/development

The latter is the reason why we removed single quotes in the env files: #56

The fact that these files need to be parsed by two different tools (bash and docker-compose) is a source of confusion. I think that we should resolve that by making sure that these files are parsed only by bash. This way, we can add "..." quotes to the env files and stop bothering whether docker-compose will parse them correctly.

I'll open a corresponding PR.

@ghassanmas
Copy link
Member

ghassanmas commented Oct 3, 2022 via email

@regisb
Copy link
Contributor Author

regisb commented Oct 3, 2022

Why not bind production to .env and development to .env.development doing that would allow to change configuration without relying on env variables.

Hmmm... that's possible, but:

  1. In development, are values from .env also loaded? If yes, in which order? If not then we need to list all variables in .env.development: currently this is not the case, because development values only override production values.
  2. Do environment variables override values in .env/.env.development? We need to make it possible for some MFEs to override certain values, as we currently do with *_MFE_APP["env"]["production"].

Generally speaking, I wouldn't touch webpack tools with a ten foot pole, but if we can simplify the loading and overriding of settings by better leveraging webpack-env, then I'm all for it.

@arbrandes what are your thoughts on this?

regisb added a commit that referenced this issue Oct 3, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close #61.
@ghassanmas
Copy link
Member

ghassanmas commented Oct 6, 2022

1.In development, are values from .env also loaded? If yes, in which order? If not then we need to list all variables in .env.development: currently this is not the case, because development values only override production values.

I don't think so, the relevant code I found about this frontend-build, is that you can .env.private file which would override, .env.development:
ref code
ref doc

  1. Do environment variables override values in .env/.env.development? We need to make it possible for some MFEs to override certain values, as we currently do with *_MFE_APP["env"]["production"].

Yes I tested this the other day, not through *_MFE_APP["env"]["production"] per say, I injected env varaiable before the bash command, i.e. NAME=VALUE npm run build that ovrirde the value in .env file.

@arbrandes
Copy link
Collaborator

@regisb, @ghassanmas, just an ACK, for now: I'll take a look at the PR shortly.

@arbrandes arbrandes self-assigned this Oct 6, 2022
@arbrandes arbrandes added this to the Olive Release Candidate milestone Oct 17, 2022
regisb added a commit that referenced this issue Nov 15, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close #61.
regisb added a commit that referenced this issue Nov 15, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close #61.
regisb added a commit that referenced this issue Nov 15, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close #61.
@arbrandes
Copy link
Collaborator

Why not bind production to .env and development to .env.development

I'd rather leave those with each MFE's default values, and instead use the process environment to override them. This is more in line with how Docker does things. (Principle of Least Surprise, and all.)

Which is what @regisb is doing in the PR which I'm about to approve.

@ghassanmas
Copy link
Member

Aha make sense, by the way are you going to keep env/* files after #69, my understanding is that we are going to remove, them right?, and then the we somehow are going just set only needed variables for build, i.e. the first point in #86, also other you mention in a comment at #69

@arbrandes
Copy link
Collaborator

arbrandes commented Nov 16, 2022

@ghassanmas, we can't remove env files as part of #69: there still needs a way for Tutor to override the default values non-dynamically per MFE, including the all-important config API URL.

We could do it via patch to the Django settings files, but that only gets fetched after initialization.

regisb added a commit that referenced this issue Nov 17, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close #61.
ghassanmas pushed a commit to ghassanmas/tutor-mfe that referenced this issue Nov 23, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close overhangio#61.
ghassanmas pushed a commit to ghassanmas/tutor-mfe that referenced this issue Nov 30, 2022
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close overhangio#61.
navinkarkera pushed a commit to open-craft/tutor-mfe that referenced this issue Mar 24, 2023
With this change, we avoid the problem of having to escape env variables
altogether. Previously, env variables were loaded both by bash (in development)
and docker-compose (in production). This meant that we had to deal with
escaping in both contexts, which was the source of trouble. We resolve this by
loading env vars only with bash.

Close overhangio#61.

(cherry picked from commit 9b1b08f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Development

Successfully merging a pull request may close this issue.

3 participants