Skip to content

Default CLI values are converted to strings #1182

Closed

Description

@jvherweg

Environment

  • Server version: 3.0.0

Description

Specifically, in the KeyExtractor in the constructor: https://github.com/solid/community-server/blob/330b645236c38dcc3b0a0c1de68ebcb25eb437f1/src/init/variables/extractors/KeyExtractor.ts#L12
The defaultValue will be a string, even if it is set as a boolean in the config as here: https://github.com/solid/community-server/blob/330b645236c38dcc3b0a0c1de68ebcb25eb437f1/config/app/variables/resolver/resolver.json#L51

This is on Components.js version 4.5.0, I did not check yet if this would be fixed with the new upcoming major release. Will check later to determine if the issue has to be moved there.

One consequence of this is that stack traces now always get printed on error pages with no way to disable it.

Activity

  1. jvherweg commented on Mar 1, 2022

    @jvherweg
    MemberAuthor

    Did a test on Component.js v5/Generator v3 and unfortunately the issue is still there. We might have to look into a solution to work around that.

  2. wkerckho commented on May 11, 2022

    @wkerckho
    Contributor

    As a workaround, we could rewrite the KeyExtractor constructor as:

    public constructor(key: string, defaultValue?: number | boolean | unknown)

    It appears that the order of the union declaration determines how Components.js tries to parse the value: first as number, then boolean, and then fallback to how it behaves currently (parse as string). A drawback of this approach is that e.g. "3000" will be parsed as a number and not as a string..

    An alternative solution could be to add an optional parameter that allows to specify the type explicitly (enabling KeyExtractor to handle edge cases).

  3. jvherweg commented on May 11, 2022

    @jvherweg
    MemberAuthor

    We should probably first investigate how much effort this would be to fix in Components.js itself. And with "investigate" I mean poking @rubensworks.

  4. self-assigned this
    on May 13, 2022
  5. wkerckho commented on May 20, 2022

    @wkerckho
    Contributor

    I've fixed this in Components.js (with the help of @rubensworks). The fix is being released as 5.2.0.
    Do I create a chore for updating the Components.js dependency?

  6. jvherweg commented on May 20, 2022

    @jvherweg
    MemberAuthor

    Do I create a chore for updating the Components.js dependency?

    Yes please, thanks!

    So starting the server with no extra CLI parameters no longer shows the stack trace in case of errors then?

  7. wkerckho commented on May 24, 2022

    @wkerckho
    Contributor

    This seems to be the case (I did a quick test by having the server return a 404 for a non-existing container, the stack trace is gone when using Components.js 5.2.0). This is the desired behaviour?

  8. jvherweg commented on May 24, 2022

    @jvherweg
    MemberAuthor

    Yes it is, it should only appear when you start the server with the -t flag, which is parsed by the classes mentioned above.

  9. jvherweg commented on Jun 1, 2022

    @jvherweg
    MemberAuthor

    Done in #1333

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

🐛 bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions