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

sync: handle TOML parsing exception for metadata.toml #617

Open
ee7 opened this issue Jun 17, 2022 · 0 comments
Open

sync: handle TOML parsing exception for metadata.toml #617

ee7 opened this issue Jun 17, 2022 · 0 comments
Labels
cmd: sync kind: bug User-facing incorrect behavior

Comments

@ee7
Copy link
Member

ee7 commented Jun 17, 2022

Follow-up from #614.

configlet sync will produce an unhandled exception if the user's cached prob-specs dir contains an invalid metadata.toml file, or if its values are of the wrong type.

proc parseMetadataToml(path: string): UpstreamMetadata =
## Parses the problem-specifications `metadata.toml` file at `path`, and
## returns an object containing the `blurb`, `source`, and `source_url` values.
let t = parsetoml.parseFile(path)
result = UpstreamMetadata(
blurb:
if t.hasKey("blurb"): t["blurb"].getStr() else: "",
source:
if t.hasKey("source"): t["source"].getStr().some() else: none(string),
source_url:
if t.hasKey("source_url"): t["source_url"].getStr().some() else: none(string)
)

But it's unlikely that anybody notices: the unhandled exception should only occur if a user has manually edited a metadata.toml file in their prob-specs cache to contain invalid TOML, and we have some protection against invalid prob-specs cache states.

However, the prob-specs CI doesn't currently lint metadata.toml files, so we do currently depend on prob-specs reviewers for the metadata.toml files to be valid upstream. I've opened exercism/problem-specifications#2061 to track that.

@ee7 ee7 added kind: bug User-facing incorrect behavior cmd: sync labels Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmd: sync kind: bug User-facing incorrect behavior
Projects
None yet
Development

No branches or pull requests

1 participant