Skip to content

core: give a nicer error message on invalid aliases - #24728

Merged
keszybz merged 1 commit into
systemd:mainfrom
jacekmigacz:bz2123927-invalid-cross-device-link
Oct 25, 2022
Merged

keszybz merged 1 commit into
systemd:mainfrom
jacekmigacz:bz2123927-invalid-cross-device-link

Conversation

@jacekmigacz

Copy link
Copy Markdown
Contributor

Gives more descriptive (but general) error message on invalid alias; instead of Invalid cross-device link.

@yuwata yuwata changed the title shared: give a nicer error message on invalid aliases core: give a nicer error message on invalid aliases Sep 18, 2022
@yuwata yuwata added the pid1 label Sep 18, 2022
@jacekmigacz
jacekmigacz force-pushed the bz2123927-invalid-cross-device-link branch from 3c4069d to 923a5e8 Compare September 19, 2022 08:23
Comment thread src/core/dbus-manager.c Outdated

case -EXDEV:
r = sd_bus_error_setf(error, BUS_ERROR_BAD_UNIT_SETTING,
"\"%s\" is an invalid alias.", changes[i].path);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

hmm, I think we should say in which way "invalid".

i.e. maybe \"%s\" unit alias doesn't match unit name or so

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.

I've used the generic message on purpose.
A that point - in dbus-manager.c - it is hard to say more; since UnitFileChange's instance is carrying an errno only.
It can be: invalid unit name, source-target mismatch or an incompatible suffix (these details should be logged by log_full_errno.
My point is, for the cli it is still better to see, that there is something wrong with an unit, instead of generic errno readout.

@poettering

Copy link
Copy Markdown
Member

lgtm. i think the wording could be improve a tiny bit still, see above

/cc @keszybz

@poettering

Copy link
Copy Markdown
Member

also see the messages generated in unit_file_dump_changes() for the EXDEV case. Might as well copy those message strings literally.

@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Sep 27, 2022
@keszybz

keszybz commented Sep 28, 2022

Copy link
Copy Markdown
Member

Hmmm, there's more discrepancies between unit_file_dump_changes() and here. Those two should be brought in alignment again, i.e. the cases that are there but missing here should be added.

Also, please add a note in unit_file_dump_changes() to update install_error(). We have the note in install_error(), but not the other way.

keszybz added a commit to keszybz/systemd that referenced this pull request Oct 20, 2022
@keszybz

keszybz commented Oct 20, 2022

Copy link
Copy Markdown
Member

#25080 does some preparatory work. This pull request is still wanted. It should be rebased on top of that other one.

@jacekmigacz
jacekmigacz force-pushed the bz2123927-invalid-cross-device-link branch 2 times, most recently from 739bbbc to d245c65 Compare October 24, 2022 19:10
@yuwata yuwata removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks needs-rebase labels Oct 24, 2022
@keszybz

keszybz commented Oct 25, 2022

Copy link
Copy Markdown
Member

Same comment as before: please add all missing cases to install_error(). EBADSLT, EIDRM, EUNATCH. Also change the order to match.

@keszybz keszybz added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Oct 25, 2022
@jacekmigacz
jacekmigacz force-pushed the bz2123927-invalid-cross-device-link branch from d245c65 to 624f788 Compare October 25, 2022 12:10
@yuwata yuwata removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Oct 25, 2022
Comment thread src/core/dbus-manager.c Resolved
@jacekmigacz
jacekmigacz force-pushed the bz2123927-invalid-cross-device-link branch from 624f788 to 52a71ad Compare October 25, 2022 13:59

@keszybz keszybz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM.

@keszybz keszybz added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed labels Oct 25, 2022
@keszybz
keszybz merged commit c89d0c3 into systemd:main Oct 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

4 participants