# Where should extension developers put configuration settings?

**URL:** <https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062>\
**Category:** JupyterLab\
**Created:** [July 21, 2021, 1:21pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062 "2021-07-21T13:21:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![adpatter](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/adpatter/32/21229_2.png) [@adpatter](https://discourse.jupyter.org/u/adpatter)\
**Post date:** [July 21, 2021, 1:21pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/1 "2021-07-21T13:21:18Z")

</div>

Is there a particular place where extension developers should be putting configuration settings for their extensions that cannot be overridden by the user? For example, I explored the Settings facility. `overrides.json` allows for default settings to be specified for extensions. However, these settings can be overridden by the user. Is there something like `overrides.json` where an extension can pull default settings from that cannot be overridden by the user?

I know I can create a server extension that can serve up default settings, but I am wondering if there is a canonical way of doing this.

---

<div class="post-metadata">

**Author:** ![bollwyvl](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bollwyvl/32/904_2.png) [@bollwyvl](https://discourse.jupyter.org/u/bollwyvl)\
**Post date:** [July 21, 2021, 2:28pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/2 "2021-07-21T14:28:18Z")

</div>

The settings bundle you get back will give you the [`default(key: string)`](https://github.com/jupyterlab/jupyterlab/blob/eea93fdc81f2c7f19490177e471a4d36d548fd38/packages/settingregistry/src/settingregistry.ts#L757) value for a particular key. There’s no particular way to prevent a user from setting a value to the key, as [`readOnly`](https://json-schema.org/draft/2019-09/json-schema-validation.html#rfc.section.9.4) probably doesn’t work, so the user’s value would come back in `.composite`, but if your code doesn’t _look_ at it…

For better build-time change detection/typing, with a bit of `tsconfig.json` jiggery pokery, you can get access to your raw schema, and work with it directly, but may have to unwrap things yourself, if you get fancy with `$ref`.

```auto
package.json
tsconfig.json # `includes`: `./schema/*.json` and `package.json`
schema/
  plugin.json
src/
  tsconfig.json # `references`: `../`

```

Then you can reference the JSON in src:

```auto
import * as PKG from '../package.json';
import * as SCHEMA from '../schema/plugin.json';

```

and compile the mess with:

```auto
tsc -b src

```

You’ll get some extra `tsconfig.buildinfo` files, the name/location of which can also be tuned, and the json will get shipped twice to the browser, but it can be worth it… having the full JSON means you can invest time in the schema, reusing `title` and `description` (and even regular expressions) in your code, so they can’t get out of sync.

---

<div class="post-metadata">

**Author:** ![adpatter](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/adpatter/32/21229_2.png) [@adpatter](https://discourse.jupyter.org/u/adpatter)\
**Post date:** [July 21, 2021, 2:31pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/3 "2021-07-21T14:31:57Z")

</div>

Thank you. This is great. I will experiment with these approaches.

I tried setting a Setting to readOnly in the JSON schema file, and in fact it didn’t have the expected effect.

Thanks again.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [July 21, 2021, 7:14pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/4 "2021-07-21T19:14:40Z")

</div>

UX-wise I would not use the `.default` method (this would be so confusing for users), unless for deprecation (“this setting is now inactive and was only left to prevent breaking validation of your config file”).

---

<div class="post-metadata">

**Author:** ![amirathi](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/amirathi/32/297_2.png) [@amirathi](https://discourse.jupyter.org/u/amirathi)\
**Post date:** [July 27, 2021, 5:25am UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/5 "2021-07-27T05:25:10Z")

</div>

If no changes are expected then why not just make it a constant in the extension codebase? I mean why even make it a Jupyter config. 🤔

---

<div class="post-metadata">

**Author:** ![adpatter](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/adpatter/32/21229_2.png) [@adpatter](https://discourse.jupyter.org/u/adpatter)\
**Post date:** [July 27, 2021, 12:01pm UTC](https://discourse.jupyter.org/t/where-should-extension-developers-put-configuration-settings/10062/6 "2021-07-27T12:01:45Z")

</div>

The motivation is for the extension to be configurable by the administrator of the application as opposed to the user of the application.
