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

Discussion: What are allowed version strings when self-hosting the runtime? #27579

Closed
mdmower opened this issue Apr 5, 2020 · 10 comments · Fixed by #27687
Closed

Discussion: What are allowed version strings when self-hosting the runtime? #27579

mdmower opened this issue Apr 5, 2020 · 10 comments · Fixed by #27687

Comments

@mdmower
Copy link
Contributor

mdmower commented Apr 5, 2020

I'd like to clear-up the requirements on allowed version strings passed to

gulp dist --version_override=<version>

As part of #25873, publishers can opt to build and host the AMP runtime themselves. A guide is in preparation to support this feature (#27100). Some publishers might appreciate the ability to use their own versioning system.

The only technical requirement I'm aware of is the expectation that version must contain only characters allowed by a URL path segment (https://tools.ietf.org/html/rfc3986#section-3.3). One example where this restriction is assumed is in method calculateExtensionScriptUrl(), where rtv is not encoded before inserted in the URL. A simple way to enforce this requirement could be to stipulate version === encodeURIComponent(version), but this is admittedly more stringent than RFC3986.

Here are some simple examples that show version v1.2a doesn't blow up the world:

@mdmower
Copy link
Contributor Author

mdmower commented Apr 8, 2020

Ping @rsimha @ampproject/wg-infra

@rsimha
Copy link
Contributor

rsimha commented Apr 8, 2020

I have no fundamental objections to publishers using non-numeric versions for self hosting AMP. However, I'm not sure if there are other places in runtime code that make implicit assumptions about the format / length of the version string.

Tagging others for comment:

@danielrozenberg wrote the date-based versioning format we currently use
@ampproject/wg-runtime @ampproject/wg-performance @ampproject/wg-ads @ampproject/wg-ui-and-a11y may be aware of other pitfalls

@jridgewell
Copy link
Contributor

It seems the JS doesn't actually depend on it being a number (at least as far as I can tell).

@kristoferbaxter
Copy link
Contributor

What do we think about requiring a number and adding a test?

@mdmower
Copy link
Contributor Author

mdmower commented Apr 8, 2020

What do we think about requiring a number and adding a test?

If I can weigh in, I think it would be great to give publishers a bit more flexibility. I'm partial to

version === encodeURIComponent(version)

but would also be fine with with something like

/^[a-z0-9.\-]+$/i.test(version)

Ultimately, I'll be happy to update my self-hosting guide with your decision and would also be willing to add a test to the build system to ensure a valid version is passed to --version_override. Thanks for the responses!

@jridgewell
Copy link
Contributor

@mdmower: Do you see a reason to use a non-standard version? Using the same 15 digit RTV pattern would be the safest, in case there's some new code in the future that expects it.

@mdmower
Copy link
Contributor Author

mdmower commented Apr 9, 2020

Do you see a reason to use a non-standard version?

In general, I avoid imposing restrictions unless there is a demonstrated need for the restriction. Here, I see an opportunity for publishers who self-host the runtime to use a versioning system they are more familiar with. The AMP Project's preference of "Date of release" style versioning is just one of many schemes. I think it'd be great to allow the flexibility, but I'm not going to complain if 15-digits is the decision.

@kristoferbaxter
Copy link
Contributor

I'd also prefer to use the same versioning scheme used by the officially released versions on the AMP CDN.

Reasons are similar to Justin, but mostly due to fear of error logging systems and similar that expect a version number of the currently official but not enforced pattern.

@mdmower
Copy link
Contributor Author

mdmower commented Apr 9, 2020

No problem. I'll create a PR to enforce the version string requirement in --version_override that will close this issue. Thanks much for the discussion!

@jridgewell
Copy link
Contributor

Also note that version_override replaces the datetime portion (the AMP version), which is 13 digits.

The RTV (15 digits) is created when a config is concatted on the v0.js file. The config is differentiated by the two leading digits. All source code is the same between AMP versions, even with different RTV prefixes.

mdmower added a commit to mdmower/amphtml that referenced this issue Apr 10, 2020
Version must be 13 digits. Combined with a 2-digit config code, this
implies RTVs must be 15 digits.

Fixes ampproject#27579
kristoferbaxter pushed a commit that referenced this issue Apr 10, 2020
Version must be 13 digits. Combined with a 2-digit config code, this
implies RTVs must be 15 digits.

Fixes #27579
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants