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

Fix manifest_version as a section bug. #225

Merged
merged 6 commits into from
Mar 19, 2021

Conversation

Integralist
Copy link
Collaborator

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 a manifest_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 running compute build fixed the issue because the fixes in 0.26.0 meant we would persist the correct manifest_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...

authors = ["integralist@fastly.com"]
description = "..."
language = "rust"
[manifest_version]
name = "..."
service_id = "..."

Using the toml parser to delete the [manifest_version] would cause name and service_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.

@Integralist Integralist requested review from phamann, a team and doramatadora and removed request for a team March 19, 2021 12:11
@Integralist Integralist added the bug Something isn't working label Mar 19, 2021
Copy link
Member

@phamann phamann left a 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.

pkg/compute/manifest/manifest.go Show resolved Hide resolved
pkg/compute/manifest/manifest.go Outdated Show resolved Hide resolved
pkg/compute/manifest/manifest.go Outdated Show resolved Hide resolved
Integralist and others added 4 commits March 19, 2021 13:34
Copy link
Contributor

@doramatadora doramatadora left a 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!

pkg/compute/manifest/manifest.go Show resolved Hide resolved
pkg/compute/manifest/manifest.go Show resolved Hide resolved
@Integralist Integralist merged commit 39c2b20 into master Mar 19, 2021
@Integralist Integralist deleted the integralist/20210319_manifest_bug branch March 19, 2021 14:54
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
None yet
Development

Successfully merging this pull request may close these issues.

4 participants