Skip to content

Improve error handling and printed output of flatpak-coredumpctl - #6649

Merged
swick merged 9 commits into
flatpak:mainfrom
electricbrass:coredumpctl-fixes
May 27, 2026
Merged

swick merged 9 commits into
flatpak:mainfrom
electricbrass:coredumpctl-fixes

Conversation

@electricbrass

Copy link
Copy Markdown
Contributor

Fixes #6270

This is the first of a few planned PRs to fix and improve flatpak-coredumpctl.

Changes made by this PR:

  1. Strings are now consistently quoted with double quotes. They were very inconsistent before. I chose double quotes because they seemed a bit more common throughout the file, and there were more strings that contained single quotes inside the string than the other way around.
  2. printf-style format strings have been replaced with f-strings for readability.
  3. When printing the flatpak command, shlex.join is used to present a more readable output.

Before:

Running: `"flatpak" "run" "--filesystem=home" "--filesystem=/tmp" "--command=gdb" "--devel" "net.odamex.Odamex" "/app/bin/odamex" "/tmp/tmpwhotdzk2"`

After:

Running: `flatpak run --filesystem=home --filesystem=/tmp --command=gdb --devel net.odamex.Odamex /app/bin/odamex /tmp/tmpgn2_hiwl`
  1. The ""Executable [exe] doesn't seem to be a flatpaked application." error message is now only printed if the path does not start with "/newroot" or "/app". Previously it only checked for "/newroot", which is no longer present, due to changes in bwrap. This meant the warning was printed out even if the executable was in a Flatpak.
  2. When running coredumpctl dump, exceptions are now caught, with the error message from coredumpctl being printed out. Previously the exception was uncaught, leading to the output seen in [Bug]: flatpak-coredumpctl crashes when -m is provided with an invalid argument. #6270.
  3. Similarly, the flatpak command uses subprocess.run instead of subprocess.check_call. Instead of raising an exception, it calls sys.exit with the return code from the flatpak command.

I couldn't find any documentation anywhere about the targeted Python version for flatpak-coredumpctl or flatpak-bisect. The changes in this PR have a minimum required version of 3.8 because of shlex.join and f-strings. The current version is compatible with down to 3.3.

Example output:
Flatpak does not exist/is not installed:
image

-m finds no matches:
image

@bbhtt bbhtt left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commits should be prefixed by flatpak-coredumpctl: and the length needs to be <=72 chars. Also make sure to put some description where suitable about what and why of the change (linking issues etc. or your personal opinion).

Comment thread scripts/flatpak-coredumpctl Outdated
Comment thread scripts/flatpak-coredumpctl
Comment thread scripts/flatpak-coredumpctl Outdated
options = parser.parse_args(namespace=coredumper)
if not coredumper.clean_args():
parser.print_help()
parser.print_help(sys.stderr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should explain why this is being changed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In most programs that print the help message due to missing/incorrect arguments, it gets printed to stderr instead of stdout. I'm cleaning up the commit messages now and will add this to the description.

Comment thread scripts/flatpak-coredumpctl Outdated
Comment thread scripts/flatpak-coredumpctl
Comment thread scripts/flatpak-coredumpctl Outdated
@bbhtt

bbhtt commented May 7, 2026

Copy link
Copy Markdown
Collaborator

I couldn't find any documentation anywhere about the targeted Python version for flatpak-coredumpctl or flatpak-bisect.

The build indeed does not define a minimum version and there aren't any runtime checks in the scripts either. Maybe it should have one or both of those.

If the minimum is getting raised, this cannot be backported to 1.16.x. If that's ok, and it's going to land in the unstable and new stable 1.18.x, I think using upto 3.10 is ok if that's what you need. I'm sceptical about supporting EOL Python versions.

Comment thread scripts/flatpak-coredumpctl Outdated
@electricbrass

Copy link
Copy Markdown
Contributor Author

the length needs to be <=72 chars

Is that the total length including the flatpak-coredumpctl:?

@electricbrass

Copy link
Copy Markdown
Contributor Author

If the minimum is getting raised, this cannot be backported to 1.16.x. If that's ok, and it's going to land in the unstable and new stable 1.18.x, I think using upto 3.10 is ok if that's what you need. I'm sceptical about supporting EOL Python versions.

My intention was for this to go to 1.17/1.18. If you would rather it be able to go into 1.16, I can revert the changes that raised the minimum version, but it would definitely be nicer to be able to use 3.10.

@electricbrass
electricbrass force-pushed the coredumpctl-fixes branch 2 times, most recently from f3723c2 to 1463ac6 Compare May 12, 2026 21:41
@swick

swick commented May 13, 2026

Copy link
Copy Markdown
Collaborator

Is that the total length including the flatpak-coredumpctl:?

Including the prefix

If you would rather it be able to go into 1.16, I can revert the changes

I will be releasing 1.18 very soon at which point 1.16 won't be supported anymore anyway, so I'd say don't bother.

@bbhtt

bbhtt commented May 13, 2026

Copy link
Copy Markdown
Collaborator

My intention was for this to go to 1.17/1.18.

Yes I suggest then using 3.10 to make life easier. And also encoding the requirement formally in meson.build + runtime verification.

@electricbrass

electricbrass commented May 17, 2026 •

Copy link
Copy Markdown
Contributor Author

encoding the requirement formally in meson.build

I'm not particularly familiar with meson. Would something like this in scripts/meson.build be correct?

py = import('python').find_installation('python3')
pyver = py.language_version()
if pyver.version_compare('<3.10')
  error('Python >= 3.10 is required, found ' + pyver)
endif

(And then since this affects flatpak-bisect as well, should I go ahead and put the runtime check in there too even though I'm otherwise not touching it?)

@electricbrass
electricbrass force-pushed the coredumpctl-fixes branch 2 times, most recently from 74a3351 to 15f2451 Compare May 17, 2026 19:46
@bbhtt

bbhtt commented May 19, 2026

Copy link
Copy Markdown
Collaborator

I'm not particularly familiar with meson. Would something like this in scripts/meson.build be correct?

Yes something like that.

should I go ahead and put the runtime check in there too even though I'm otherwise not touching it?)

In a later PR when it is actually relying on 3.10 features. Same for the meson.build part.

@bbhtt bbhtt assigned bbhtt and unassigned bbhtt May 19, 2026
@bbhtt

bbhtt commented May 19, 2026

Copy link
Copy Markdown
Collaborator

A few of your commits are still exceeding the width.

@electricbrass

electricbrass commented May 19, 2026 •

Copy link
Copy Markdown
Contributor Author

It looks to me like the longest is 70 characters?

Edit: Oh wait found one description line that was too long.

This fixes a bug where the warning about not being a flatpaked
application was being printed for flatpaks. This was due to a
change in bwrap so that the paths no longer start with /newroot.
Print out error messages instead of raising an uncaught exception

Replace one more set of quotes that I missed previously
This is more consistent with common practice for
help messages printed due to missing/incorrect arguments.
This prevents it from getting printed twice in some circumstances
@bbhtt

bbhtt commented May 19, 2026 •

Copy link
Copy Markdown
Collaborator

It's in body:

git commitlen HEAD~10..HEAD                                                                                                                                               
6ff20ceb flatpak-coredumpctl: Print help message to stderr
  line 3: 106 chars: This is more consistent with common practice for help messages printed due to missing/incorrect arguments.

@swick
swick added this pull request to the merge queue May 27, 2026
Merged via the queue into flatpak:main with commit 8c418fa May 27, 2026
11 checks passed
@electricbrass
electricbrass deleted the coredumpctl-fixes branch May 31, 2026 02:25
@mcatanzaro mcatanzaro mentioned this pull request Jun 8, 2026
4 tasks done
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.

[Bug]: flatpak-coredumpctl crashes when -m is provided with an invalid argument.

3 participants