-
Notifications
You must be signed in to change notification settings - Fork 59
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
Fix manifest_version as a section bug. #225
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm still personally on the fence if we should even ship this, without other systems in place to ensure we will delete the code in a timely fashion. However, I do understand that this is a genuine user issue in the wild and thus happy to review.
TL;DR looks like a clean implementation to me 👍🏻 have left a couple of minor style nits but nothing blocking.
Co-authored-by: Patrick Hamann <patrick@fastly.com>
Co-authored-by: Patrick Hamann <patrick@fastly.com>
This reverts commit b245fcf.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to my non-SME eyes — spotted a typo!
Problem
There was a report by someone at Fastly earlier in the week regarding an issue with the
0.25.0
CLI release. The issue was caused by an existing compute project they had which used a fastly.toml without amanifest_version
set.Ultimately the end result was that the
manifest_version
field was being stored in the fastly.toml as a 'section', e.g.[manifest_version]
which completely changes the interpretation of the toml file and would cause the toml parser to error when encountering it.Removing
[manifest_version]
before runningcompute build
fixed the issue because the fixes in0.26.0
meant we would persist the correctmanifest_version
value back to the manifest file, but this is still confusing behaviour for any users who might have stumble into this.Solution
Before we attempt to unmarshal the toml data we first need to identify if the manifest contains a
manifest_version
as a 'section'.Once we've identified if it is set as a section (e.g.
[manifest_version]
), we can then proceed to remove it from the file.Notes
I had initially hoped to have used the toml parsing library to support the deletion of the
[manifest_version]
section (e.g. delete the section and then use the existing Write() method to overwrite the manifest file) but unfortunately because I can't guarantee the location of the manifest_version field within the manifest file it could mean we accidentally end up deleting a larger chunk of the configuration.For example...
Using the toml parser to delete the
[manifest_version]
would causename
andservice_id
to also be deleted as they are mistakenly interpreted as being within that same section block.This means I have to take a different approach, which is to read the manifest line by line and to remove the
[manifest_version]
that way.