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

Generate empty report correctly #828

Merged
merged 2 commits into from May 9, 2023

Conversation

pirat89
Copy link
Member

@pirat89 pirat89 commented May 5, 2023

On Python2, the json.dumps library can produce either unicode or str output. Nowadays, the unicode is required, however in case the input for json.dumps function does not contain any unicode objects (e.g. when no report entry exists), it produces str type.

Also ensure the generated json file has the empty newline in the end of the file.

Relates: #821
JIRA: OAMG-8996

Additional info:

(Pdb) json.dumps({'entries': [], 'leapp_run_id': context}, indent=2, ensure_ascii=False)
'{\n  "leapp_run_id": "c6aa7f2a-7aaf-4fc0-9bd3-667f81395e9f", \n  "entries": []\n}'
(Pdb) json.dumps({'entries': ["foo"], 'leapp_run_id': context}, indent=2, ensure_ascii=False)
'{\n  "leapp_run_id": "c6aa7f2a-7aaf-4fc0-9bd3-667f81395e9f", \n  "entries": [\n    "foo"\n  ]\n}'
(Pdb) json.dumps({'entries': [u"foo"], 'leapp_run_id': context}, indent=2, ensure_ascii=False)
u'{\n  "leapp_run_id": "c6aa7f2a-7aaf-4fc0-9bd3-667f81395e9f", \n  "entries": [\n    "foo"\n  ]\n}'
(Pdb) 

Original issue when an empty report has been generated:

Traceback (most recent call last):
  File "/usr/bin/leapp", line 9, in <module>
    load_entry_point('leapp==0.15.1', 'console_scripts', 'leapp')()
  File "/usr/lib/python2.7/site-packages/leapp/cli/__init__.py", line 45, in main
    cli.command.execute('leapp version {}'.format(VERSION))
  File "/usr/lib/python2.7/site-packages/leapp/utils/clicmd.py", line 111, in execute
    args.func(args)
  File "/usr/lib/python2.7/site-packages/leapp/utils/clicmd.py", line 133, in called
    self.target(args)
  File "/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/breadcrumbs.py", line 163, in wrapper
    return f(*args, breadcrumbs=breadcrumbs, **kwargs)
  File "/usr/lib/python2.7/site-packages/leapp/cli/commands/preupgrade/__init__.py", line 78, in preupgrade
    util.generate_report_files(context, report_schema)
  File "/usr/lib/python2.7/site-packages/leapp/cli/commands/upgrade/util.py", line 147, in generate_report_files
    generate_report_file(messages, context, report_json, report_schema)
  File "/usr/lib/python2.7/site-packages/leapp/utils/report.py", line 168, in generate_report_file
    f.write(data)
TypeError: must be unicode, not str

@pirat89 pirat89 added the bug label May 5, 2023
@github-actions
Copy link

github-actions bot commented May 5, 2023

Thank you for contributing to the Leapp project!

Please note that every PR needs to comply with the Leapp Guidelines and must pass all tests in order to be mergeable.
If you want to request a review or rebuild a package in copr, you can use following commands as a comment:

  • review please @oamg/developers to notify leapp developers of the review request
  • /packit copr-build to submit a public copr build using packit

To launch regression testing public members of oamg organization can leave the following comment:

  • /rerun to schedule basic regression tests using this pr build and leapp-repository*master* as artifacts
  • /rerun 42 to schedule basic regression tests using this pr build and leapp-repository*PR42* as artifacts
  • /rerun-sst to schedule sst tests using this pr build and leapp-repository*master* as artifacts
  • /rerun-sst 42 to schedule sst tests using this pr build and leapp-repository*PR42* as artifacts

Please open ticket in case you experience technical problem with the CI. (RH internal only)

Note: In case there are problems with tests not being triggered automatically on new PR/commit or pending for a long time, please consider rerunning the CI by commenting leapp-ci build (might require several comments). If the problem persists, contact leapp-infra.

@fernflower
Copy link
Member

/rerun

@github-actions
Copy link

github-actions bot commented May 5, 2023

Copr build succeeded: https://copr.fedorainfracloud.org/coprs/build/5890445

On Python2, the json.dumps library can produce either
unicode or str output. Nowadays, the unicode is required, however
in case the input for json.dumps function does not contain any
unicode objects (e.g. when no report entry exists), it produces
str type.

Relates: oamg#821
@pirat89
Copy link
Member Author

pirat89 commented May 5, 2023

@fernflower aah. copy&paste error /o\ should be fixed now

Text files should have empty newline in the end of the file to be
POSIX compatible.
@pirat89
Copy link
Member Author

pirat89 commented May 5, 2023

/rerun

@pirat89 pirat89 added the changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant label May 5, 2023
@github-actions
Copy link

github-actions bot commented May 5, 2023

Copr build succeeded: https://copr.fedorainfracloud.org/coprs/build/5890572

@github-actions
Copy link

github-actions bot commented May 5, 2023

Testing Farm request for RHEL-7.9-rhui/5886104;5890445 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 5, 2023

Testing Farm request for RHEL-8.6-rhui/5886104;5890572 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 5, 2023

Testing Farm request for RHEL-7.9-rhui/5886104;5890572 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@pirat89 pirat89 requested a review from fernflower May 8, 2023 09:17
@fernflower
Copy link
Member

/rerun

@github-actions
Copy link

github-actions bot commented May 9, 2023

Copr build succeeded: https://copr.fedorainfracloud.org/coprs/build/5900120

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-8.6-rhui/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-7.9-rhui/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-8.6.0-Nightly/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-8.8.0-Nightly/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-7.9-ZStream/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@github-actions
Copy link

github-actions bot commented May 9, 2023

Testing Farm request for RHEL-7.9-ZStream/5886104;5900120 regression testing has been created.
Once finished, results should be available here.
Full pipeline log.

@fernflower fernflower merged commit 032c009 into oamg:master May 9, 2023
14 checks passed
@pirat89 pirat89 deleted the fix-empty-report-unicode branch May 9, 2023 15:27
pirat89 added a commit to pirat89/leapp that referenced this pull request Aug 23, 2023
## Packaging
-  Provide leapp-framework 5.0 (oamg#818, oamg#840)

## Framework
### Fixes
- Improve processing of reports with UTF-8 characters (oamg#821, oamg#828)
- Fix info reporting with only one path to log (oamg#834)

### Enhancements
- Include tracebacks of actors into the leapp.db (oamg#832)

## Leapp (tool)
### Fixes
- Dialog creation fails not more for a component without choices (oamg#826)
- Empty report is generated correctly (oamg#828)
- Fix processing data in remediation instructions with non-ascii characters ()

### Enhancements
- Improve report summary output to make it more visible (oamg#818, oamg#840)

## stdlib
### Fixes
- Fixed the call when the execute cannot be performed (oamg#836)
### Enhancements
- changes related just to stdlib - under leapp/libraries/stdlib
@pirat89 pirat89 mentioned this pull request Aug 23, 2023
pirat89 added a commit to pirat89/leapp that referenced this pull request Aug 23, 2023
## Packaging
-  Provide leapp-framework 5.0 (oamg#818, oamg#840)

## Framework
### Fixes
- Improve processing of reports with UTF-8 characters (oamg#821, oamg#828)
- Fix info reporting with only one path to log (oamg#834)

### Enhancements
- Include tracebacks of actors into the leapp.db (oamg#832)

## Leapp (tool)
### Fixes
- Dialog creation fails not more for a component without choices (oamg#826)
- Empty report is generated correctly (oamg#828)
- Fix processing data in remediation instructions with non-ascii characters ()

### Enhancements
- Improve report summary output to make it more visible (oamg#818, oamg#840)

## stdlib
### Fixes
- Fixed the call when the execute cannot be performed (oamg#836)
### Enhancements
- changes related just to stdlib - under leapp/libraries/stdlib
Rezney pushed a commit that referenced this pull request Aug 23, 2023
## Packaging
-  Provide leapp-framework 5.0 (#818, #840)

## Framework
### Fixes
- Improve processing of reports with UTF-8 characters (#821, #828)
- Fix info reporting with only one path to log (#834)

### Enhancements
- Include tracebacks of actors into the leapp.db (#832)

## Leapp (tool)
### Fixes
- Dialog creation fails not more for a component without choices (#826)
- Empty report is generated correctly (#828)
- Fix processing data in remediation instructions with non-ascii characters ()

### Enhancements
- Improve report summary output to make it more visible (#818, #840)

## stdlib
### Fixes
- Fixed the call when the execute cannot be performed (#836)
### Enhancements
- changes related just to stdlib - under leapp/libraries/stdlib
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug changelog-checked The merger/reviewer checked the changelog draft document and updated it when relevant
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants