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

(improvement, fern): Add better error for invalid generators.yml #3521

Merged
merged 3 commits into from May 14, 2024

Conversation

amckinney
Copy link
Collaborator

This improves the fern compiler's error reporting when the user's generators.yml is invalid. For example, suppose you have the following configuration with duplicate map keys (i.e. publish):

groups:
  publish:
    generators:
      - name: fernapi/fern-go-sdk
        version: 0.21.1
        github:
          repository: acme/acme-go
  publish:
    generators:
      - name: fernapi/fern-python-sdk
        version: 1.4.0
        github:
          repository: acme/acme-python

The CLI would previously fail with an unhelpful error message like the following:

$ fern generate
Missing file: api.yml

This was because we would ignore any errors thrown by the generators.yml, even if the file existed. This refactors the approach so that we actually act upon the errors thrown by the generators.yml parser and surface it to the user. Now, the user will see the following:

$ fern generate
Failed to parse generators.yml: duplicated mapping key

@amckinney amckinney requested a review from dsinghvi as a code owner May 3, 2024 15:50
Copy link
Member

@dsinghvi dsinghvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! 🚀 If there are multiple generators.yml files should we be logging the filepath of the erroneous one?

@amckinney
Copy link
Collaborator Author

Great call, updated!

@amckinney amckinney merged commit b5f6099 into main May 14, 2024
27 checks passed
@amckinney amckinney deleted the amckinney/fern/validate branch May 14, 2024 13:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants