Skip to content

Clean up nested control flow#807

Merged
jasonforal merged 2 commits intomainfrom
jf/get_config
Feb 9, 2026
Merged

Clean up nested control flow#807
jasonforal merged 2 commits intomainfrom
jf/get_config

Conversation

@jasonforal
Copy link
Collaborator

@jasonforal jasonforal commented Feb 6, 2026

What problem are you trying to solve?

As part of the config file v2 rollout, I need to be able to detect if a local configuration file is v1 or v2 and adjust control flow accordingly (until the config merge endpoint on the backend can be updated, the analyzer needs to error when handling a v2 config).

get_config has highly-nested control flow, making this difficult to do in an understandable way.

What is your solution?

  • Flatten the control flow using more idiomatic Rust.
  • Read the file once as a String, and then parse to ConfigFile or convert to base64 from that String

What the reviewer should know

  • This function can no longer panic: the usage of expect was replaced with proper Result propagation (anyhow::Context).

@jasonforal jasonforal requested a review from a team as a code owner February 6, 2026 15:56
@datadog-datadog-prod-us1

This comment has been minimized.

@jasonforal jasonforal merged commit e4f7dfd into main Feb 9, 2026
81 checks passed
@jasonforal jasonforal deleted the jf/get_config branch February 9, 2026 20:48
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.

2 participants