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

Raise an exception if a "plugins" block exists in metadata.json #2190

Merged
merged 2 commits into from
Oct 12, 2023

Conversation

asg017
Copy link
Collaborator

@asg017 asg017 commented Sep 18, 2023

refs #2183 #2093

From this comment in #2183: If a "plugins" block appears in metadata.json, it means that a user hasn't migrated over their plugin configuration from metadata.json to datasette.yaml, which is a breaking change in Datasette 1.0.

This PR will ensure that an error is raised whenever that happens.


📚 Documentation preview 📚: https://datasette--2190.org.readthedocs.build/en/2190/

@codecov
Copy link

codecov bot commented Sep 18, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: -0.03% ⚠️

Comparison is base (6ed7908) 92.69% compared to head (fc7dbe0) 92.67%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2190      +/-   ##
==========================================
- Coverage   92.69%   92.67%   -0.03%     
==========================================
  Files          40       40              
  Lines        6039     6044       +5     
==========================================
+ Hits         5598     5601       +3     
- Misses        441      443       +2     
Files Changed Coverage Δ
datasette/app.py 94.19% <100.00%> (ø)
datasette/cli.py 82.53% <100.00%> (ø)
datasette/utils/__init__.py 94.83% <100.00%> (+0.03%) ⬆️

... and 1 file with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@asg017
Copy link
Collaborator Author

asg017 commented Sep 21, 2023

TODO: add similar checks for permissions/allow/canned queries

@simonw
Copy link
Owner

simonw commented Oct 12, 2023

This looks good and works well. The error from this currently looks like:

datasette -m metadata.json -p 8844
Traceback (most recent call last):
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/bin/datasette", line 33, in <module>
    sys.exit(load_entry_point('datasette', 'console_scripts', 'datasette')())
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/simon/.local/share/virtualenvs/datasette-AWNrQs95/lib/python3.10/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/Users/simon/Dropbox/Development/datasette/datasette/cli.py", line 98, in wrapped
    return fn(*args, **kwargs)
  File "/Users/simon/Dropbox/Development/datasette/datasette/cli.py", line 546, in serve
    metadata_data = fail_if_plugins_in_metadata(parse_metadata(metadata.read()))
  File "/Users/simon/Dropbox/Development/datasette/datasette/utils/__init__.py", line 1282, in fail_if_plugins_in_metadata
    raise Exception(
Exception: Datasette no longer accepts plugin configuration in --metadata. Move your "plugins" configuration blocks to a separate file - we suggest calling that datasette..json - and start Datasette with datasette -c datasette..json. See https://docs.datasette.io/en/latest/configuration.html for more details.

With wrapping:

Exception: Datasette no longer accepts plugin configuration in --metadata. Move your "plugins" configuration blocks to a separate file - we suggest calling that datasette..json - and start Datasette with datasette -c datasette..json. See https://docs.datasette.io/en/latest/configuration.html for more details.

I think we should link directly to documentation that tells people how to perform this upgrade.

@simonw
Copy link
Owner

simonw commented Oct 12, 2023

It would be nice if we could catch that and turn that into a less intimidating Click exception too.

@simonw
Copy link
Owner

simonw commented Oct 12, 2023

I'm going to land this and open a new issue for the upgrade instructions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants