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

mavgen: always report generator errors in the exit code #952

Conversation

MaEtUgR
Copy link
Contributor

@MaEtUgR MaEtUgR commented Jun 21, 2024

I'm thankful that @nexton-winjeel added the option to have the exit code indicate an error in #863. I'm asking myself why this isn't default. I imagine the generator to be called automatically by CI or like in my case a build step in PX4. Shouldn't it fail by default instead of silently succeeding without a certain dialect properly generated? I would have expected that.

I changed it for PX4 to explicitly add the flag in PX4/PX4-Autopilot#23313 but want to save the next developer having the hassle.

EDIT: To clarify some mistakes e.g. using a non-existing type in a message definition makes the generation throw an exception and fail early. Other mistakes like referring to a non-existing enum don't throw an exception but rather print Enum X in X does not exist and make the mavgen.mavgen() function return False. These should be caught early to not cause problems down the road in the build workflow.

Copy link
Contributor

@khancyr khancyr left a comment

Choose a reason for hiding this comment

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

agree

@hamishwillee
Copy link
Contributor

@peterbarker Can we get some eyes on this? @auturgy ?

@peterbarker
Copy link
Contributor

I'll make sure this comes up at DevCallEU. Frankly I think we should remove the option entirely and just terminate abnormally in case of error. This may break people's workflows somehow, but they were probably already subtly broken....

@MaEtUgR
Copy link
Contributor Author

MaEtUgR commented Jul 9, 2024

I think we should remove the option entirely and just terminate abnormally in case of error. This may break people's workflows somehow, but they were probably already subtly broken....

These are exactly my thoughts. I can adjust the pull request to do that instead. I just tried not to stand on anyone's foot/workflow but it must be broken if it doesn't fail upon a failure.

@tridge
Copy link
Contributor

tridge commented Jul 10, 2024

as long as with the XML in github.com/ArduPilot/mavlink and github.com/mavlink/mavlink doesn't throw errors if we enable the exit code then I'm fine making exiting with an error the default

@hamishwillee
Copy link
Contributor

@peterbarker @MaEtUgR Tested as requested by @tridge above using all.xml and ardupilotmega.xml, using both the current --exit-code and the proposed --disable-exit-code. The value has no effect on our current XML in either mavlink/mavlink or ArduPilot/mavlink message sets.

I'd prefer errors always enabled, so if that change is made would you be able to merge this @peterbarker ?

@peterbarker
Copy link
Contributor

I'd prefer errors always enabled, so if that change is made would you be able to merge this @peterbarker ?

Yes.

@MaEtUgR MaEtUgR force-pushed the maetugr/report-generation-errors-by-default branch from f40f5ac to 21a49ba Compare July 31, 2024 09:04
@MaEtUgR MaEtUgR changed the title mavgen: report generator errors in the exit code by default mavgen: always report generator errors in the exit code Jul 31, 2024
@MaEtUgR
Copy link
Contributor Author

MaEtUgR commented Jul 31, 2024

Thanks for the feedback! I simplified the PR to always report failures via the exit code when mavgen.mavgen() returns False. I also updated the PR description to clarify that some message definition errors throw exceptions, but others are caught only by this mechanism. I retested it in the PX4 environment to confirm it behaves as expected.

Copy link
Contributor

@peterbarker peterbarker left a comment

Choose a reason for hiding this comment

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

LGTM

@peterbarker peterbarker merged commit 533161c into ArduPilot:master Jul 31, 2024
12 checks passed
@hamishwillee
Copy link
Contributor

Thanks @peterbarker and @MaEtUgR

I've pulled this up to mavlink/mavlink in mavlink/mavlink#2138 (Matthias, this gets auto-pulled into PX4 on a regular basis)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants