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

Creating new brick with mason new <NAME> with empty mason.yaml throws error. #16

Closed
mtwichel opened this issue Nov 30, 2020 · 0 comments · Fixed by #17
Closed

Creating new brick with mason new <NAME> with empty mason.yaml throws error. #16

mtwichel opened this issue Nov 30, 2020 · 0 comments · Fixed by #17
Labels
bug Something isn't working

Comments

@mtwichel
Copy link
Contributor

Steps to Reproduce

  1. Run mason init in new directory
  2. Open generated mason.yaml and delete all the contents
  3. Run mason new test

You'll receive the following stack trace:

Marcuss-MBP-2:temp mtwichel$ mason new test
Unhandled exception:
ParsedYamlException: line 1, column 1: Not a map
  ╷
1 │ 
  │ ^
  ╵
#0      checkedYamlDecode (package:checked_yaml/checked_yaml.dart:43:5)
#1      NewCommand.run (package:mason/src/commands/new_command.dart:68:23)
#2      CommandRunner.runCommand (package:args/command_runner.dart:197:27)
#3      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:112:25)
#4      new Future.sync (dart:async/future.dart:223:31)
#5      CommandRunner.run (package:args/command_runner.dart:112:14)
#6      main (file:///Users/mtwichel/.pub-cache/hosted/pub.dartlang.org/mason-0.0.1-dev.15/bin/mason.dart:27:20)
#7      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:299:32)
#8      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)

Expected Behavior

I would expect the CLI to generate a new bricks: entry in mason.yaml, then add my new brick to the file.

Background

I stumbled across this as I was trying out the new commands. The first thing I tried was mason init, said "cool this is great, I'll try it with my own template", then deleted everything that had generated from mason.yaml and tried mason new.

I believe this is occurring because the yaml parser isn't finding a valid yaml schema in the file because it's completely empty.

Potential Solutions

Two ideas I have:

  • Add try/catch to reading in mason.yaml and if something goes wrong, provide a more friendly message
  • Before parsing yaml file, make sure the file isn't empty. If it is, either show an error message or add bricks: entry

Let me know if you approve of these solution(s). I'm happy to submit a PR if need be.

@felangel felangel added the bug Something isn't working label Nov 30, 2020
alestiago pushed a commit to alestiago/mason that referenced this issue Jun 9, 2023
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 a pull request may close this issue.

2 participants