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

jrnl crashes when running jrnl --list --format json and jrnl --list --format yaml #1737

Closed
micahellison opened this issue May 6, 2023 · 0 comments · Fixed by #1711
Closed
Labels
bug Something isn't working

Comments

@micahellison
Copy link
Member

Diagnostic output

jrnl: v4.0-beta3
Python: 3.11.1 (tags/v3.11.1:a7a450f, Dec  6 2022, 19:58:39) [MSC v.1934 64 bit (AMD64)]
OS: Windows 10

Current Behavior

>jrnl --list --format yaml
┏━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  RepresenterError                                                   ┃
┃  cannot represent an object: C:\Users\micah\.config\jrnl\jrnl.yaml  ┃
┃                                                                     ┃
┃  This is probably a bug. Please file an issue at:                   ┃
┃  https://github.com/jrnl-org/jrnl/issues/new/choose                 ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

>jrnl --list --format json
┏━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  TypeError                                            ┃
┃  Object of type WindowsPath is not JSON serializable  ┃
┃                                                       ┃
┃  This is probably a bug. Please file an issue at:     ┃
┃  https://github.com/jrnl-org/jrnl/issues/new/choose   ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Expected Behavior

See related issue #1592 for how this should work.

Repro Steps

See Current Behavior above.

Debug output

I obfuscated my journals but otherwise this is it for jrnl --list --format json:

[14:01:27] DEBUG    Logging start                                                                                           main.py:32
           DEBUG    Parsed args:                                                                                            main.py:42
                    Namespace(debug=True, preconfig_cmd=None, postconfig_cmd=<function postconfig_list at
                    0x000001C5CF3004A0>, filename=None, template=None, on_date=None, today_in_history=False, month=None,
                    day=None, year=None, start_date=None, end_date=None, contains=None, strict=False, starred=False,
                    tagged=False, limit=None, excluded=[], edit=False, delete=False, change_time=None, export='json',
                    tags=False, short=False, config_override=[], config_file_path='', text=[], exclude_starred=False,
                    exclude_tagged=False)
           DEBUG    Reading configuration from file C:\Users\micah\.config\jrnl\jrnl.yaml                                install.py:91
           DEBUG    Using configuration:                                                                                install.py:117
                    "{
                        'colors': {
                            'body': 'none',
                            'date': 'black',
                            'tags': 'yellow',
                            'title': 'cyan'
                        },
                        'default_hour': 9,
                        'default_minute': 0,
                        'display_format': None,
                        'editor': 'subl -w',
                        'encrypt': False,
                        'highlight': True,
                        'indent_character': '| ',
                        'journals': {
                            ***********************************************************
                        },
                        'linewrap': 80,
                        'tagsymbols': '#@',
                        'template': False,
                        'timeformat': '%F %r',
                        'version': 'v4.0-beta3'
                    }"
           DEBUG    Using journal name: default                                                                          config.py:249
           DEBUG    Updating configuration with specific journal overrides:                                              config.py:154
                    {'encrypt': False, 'journal': 'C:\\Users\\micah\\Documents\\jrnl\\default.txt'}
           DEBUG    Scoped config:                                                                                       config.py:163
                    {
                        'colors': {
                            'body': 'none',
                            'date': 'black',
                            'tags': 'yellow',
                            'title': 'cyan'
                        },
                        'default_hour': 9,
                        'default_minute': 0,
                        'display_format': None,
                        'editor': 'subl -w',
                        'encrypt': False,
                        'highlight': True,
                        'indent_character': '| ',
                        'journals': {
                            ***********************************************************
                        },
                        'linewrap': 80,
                        'tagsymbols': '#@',
                        'template': False,
                        'timeformat': '%F %r',
                        'version': 'v4.0-beta3',
                        'journal': 'C:\\Users\\micah\\Documents\\jrnl\\default.txt'
                    }
  File "C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\main.py", line 44, in run
    status_code = controller.run(args)
                  ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\controller.py", line 63, in run
    return args.postconfig_cmd(
           ^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\commands.py", line 65, in postconfig_list
    print(list_journals(config, args.export))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\output.py", line 67, in list_journals
    return journal_list_to_json(journal_list)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\output.py", line 33, in journal_list_to_json
    return json.dumps(journal_list)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\json\__init__.py", line 231, in dumps
    return _default_encoder.encode(obj)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\json\encoder.py", line 200, in encode
    chunks = self.iterencode(o, _one_shot=True)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\json\encoder.py", line 258, in iterencode
    return _iterencode(o, 0)
           ^^^^^^^^^^^^^^^^^
  File "C:\Python311\Lib\json\encoder.py", line 180, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\main.py:44 in run                   │
│                                                                                                  │
│   43 │   │                                                                                       │
│ ❱ 44 │   │   status_code = controller.run(args)                                                  │
│   45                                                                                             │
│                                                                                                  │
│ C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\controller.py:63 in run             │
│                                                                                                  │
│    62 │   if callable(args.postconfig_cmd):                                                      │
│ ❱  63 │   │   return args.postconfig_cmd(                                                        │
│    64 │   │   │   args=args, config=config, original_config=original_config                      │
│                                                                                                  │
│ C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\commands.py:65 in postconfig_list   │
│                                                                                                  │
│    64 │                                                                                          │
│ ❱  65 │   print(list_journals(config, args.export))                                              │
│    66                                                                                            │
│                                                                                                  │
│ C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\output.py:67 in list_journals       │
│                                                                                                  │
│    66 │   if format == "json":                                                                   │
│ ❱  67 │   │   return journal_list_to_json(journal_list)                                          │
│    68 │   elif format == "yaml":                                                                 │
│                                                                                                  │
│ C:\Users\micah\.local\pipx\venvs\jrnl\Lib\site-packages\jrnl\output.py:33 in                     │
│ journal_list_to_json                                                                             │
│                                                                                                  │
│    32 │                                                                                          │
│ ❱  33 │   return json.dumps(journal_list)                                                        │
│    34                                                                                            │
│                                                                                                  │
│ C:\Python311\Lib\json\__init__.py:231 in dumps                                                   │
│                                                                                                  │
│   230 │   │   default is None and not sort_keys and not kw):                                     │
│ ❱ 231 │   │   return _default_encoder.encode(obj)                                                │
│   232 │   if cls is None:                                                                        │
│                                                                                                  │
│ C:\Python311\Lib\json\encoder.py:200 in encode                                                   │
│                                                                                                  │
│   199 │   │   # equivalent to the PySequence_Fast that ''.join() would do.                       │
│ ❱ 200 │   │   chunks = self.iterencode(o, _one_shot=True)                                        │
│   201 │   │   if not isinstance(chunks, (list, tuple)):                                          │
│                                                                                                  │
│ C:\Python311\Lib\json\encoder.py:258 in iterencode                                               │
│                                                                                                  │
│   257 │   │   │   │   self.skipkeys, _one_shot)                                                  │
│ ❱ 258 │   │   return _iterencode(o, 0)                                                           │
│   259                                                                                            │
│                                                                                                  │
│ C:\Python311\Lib\json\encoder.py:180 in default                                                  │
│                                                                                                  │
│   179 │   │   """                                                                                │
│ ❱ 180 │   │   raise TypeError(f'Object of type {o.__class__.__name__} '                          │
│   181 │   │   │   │   │   │   f'is not JSON serializable')                                       │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: Object of type WindowsPath is not JSON serializable
┏━ Error ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃  TypeError                                            ┃
┃  Object of type WindowsPath is not JSON serializable  ┃
┃                                                       ┃
┃  This is probably a bug. Please file an issue at:     ┃
┃  https://github.com/jrnl-org/jrnl/issues/new/choose   ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Other Information

No response

@micahellison micahellison added bug Something isn't working 🆕 New! labels May 6, 2023
@micahellison micahellison linked a pull request May 7, 2023 that will close this issue
4 tasks
@micahellison micahellison removed the 🆕 New! label May 20, 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.

1 participant