Show proper error message when syntax in 'RequiredBy=' is wrong

Open
#13,619 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
linux

Research direction

Reproduce the issue with the provided .service file and systemd-analyze verify automount.service, focusing on dependency handling for the [Unit] section's Before= entry. Done means the invalid pve-guests dependency produces a specific diagnostic rather than Unknown error -22, or that the documented extension behavior is clarified.

Written by the indexing model from the issue text.

Description

needs-better-log-message pid1

Is your feature request related to a problem? Please describe.
In a .service file under the [Unit] section when using the 'Before=' option and forgetting to specify the '.service' ending for services listed there, an 'Unknown Error 22' is thrown when analyzing the service file or using the service.

My specific example

[Unit]
Description=Automount Encrypted Dataset
Before=pve-guests

[Service]
Type=simple
ExecStartPre=/bin/true
ExecStart=/bin/true

[Install]
WantedBy=multi-user.target

When booting the system with this service enabled or analyzing the file via "systemd-analyze verify automount.service" the following unspecific error appears.
Failed to add dependency on pve-guests, ignoring: Unknown error -22

Took me quite some time to find my mistake since the error message is not very specific about the problem.

Describe the solution you'd like
In case this is a syntax error in systemd, the file should not be possible to load. In case this syntax is allowed but a unit with this name could not be found, the error should be something like:
Failed to add dependency on pve-guests, ignoring: Error: Unit pve-guests doesn't exist

Describe alternatives you've considered
Automatically assume '.service' extension when user didn't specify an extension.

Dominant language
C
Stars
16.7k
Forks
4.7k
Avg merge
1d 6h
Merged PRs (30d)
140

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from systemd/systemd

All issues in systemd/systemd

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.