Skip to content

fix issue when end_user_license_agreeement is defined but value is nil or empty string - #30595

Merged
ghernandez345 merged 1 commit into
mainfrom
fix-gitops-eula-undefined-key
Jul 7, 2025
Merged

fix issue when end_user_license_agreeement is defined but value is nil or empty string#30595
ghernandez345 merged 1 commit into
mainfrom
fix-gitops-eula-undefined-key

Conversation

@ghernandez345

@ghernandez345 ghernandez345 commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

relates to #28691

This fixes an issue where end_user_license_agreeement is defined but is an empty string or nil.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of the end user license agreement (EULA) field in app configuration to ensure it is always set correctly and removed from the configuration map after processing.

@coderabbitai

coderabbitai Bot commented Jul 7, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The change updates the logic for handling the "end_user_license_agreement" field in the MDM app configuration map during the GitOps application process. It now explicitly checks for the field's presence and value, assigns an appropriate value to eulaPath, and always removes the field from the map, ensuring consistent processing.

Changes

File(s) Change Summary
server/service/client.go Refined logic for extracting, assigning, and deleting the "end_user_license_agreement" field from the app config map.

Poem

A hop and a skip through the code we go,
EULA in paw, we check high and low.
If it's missing or empty, we set it just right,
Then whisk it away and hop out of sight.
Clean config, happy code—what a delight!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
server/service/client.go (1)

1805-1810: LGTM! The logic correctly handles all edge cases for the EULA field.

The new conditional logic properly addresses the issue described in the PR by explicitly handling when end_user_license_agreement is nil, empty string, or non-existent. The fix ensures eulaPath is consistently set and the key is always removed from the map.

Consider this minor refactor for improved readability and explicit edge case handling:

-		if endUserLicenseAgreement, exists := mdmAppConfig["end_user_license_agreement"]; !exists || endUserLicenseAgreement == nil || (endUserLicenseAgreement == "") {
-			eulaPath = ""
-		} else if eulaStr, ok := endUserLicenseAgreement.(string); ok && len(eulaStr) > 0 {
-			eulaPath = eulaStr
+		if endUserLicenseAgreement, exists := mdmAppConfig["end_user_license_agreement"]; !exists || endUserLicenseAgreement == nil {
+			eulaPath = ""
+		} else if eulaStr, ok := endUserLicenseAgreement.(string); ok {
+			if len(eulaStr) > 0 {
+				eulaPath = eulaStr
+			} else {
+				eulaPath = ""
+			}
+		} else {
+			// Handle non-string types explicitly
+			eulaPath = ""
 		}

This makes the handling of empty strings and non-string types more explicit, though the current implementation is functionally correct.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b2a1187 and d7c2f1e.

📒 Files selected for processing (1)
  • server/service/client.go (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (32)
  • GitHub Check: test-db-changes
  • GitHub Check: Analyze (go)
  • GitHub Check: Analyze (javascript)
  • GitHub Check: test-preview (ubuntu-latest)
  • GitHub Check: test-go (main, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (mysql, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (vuln, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (service, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (fleetctl, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (vuln, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (service, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: check-doc-gen
  • GitHub Check: build-and-check
  • GitHub Check: test-go (scripts, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (mysql, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (main, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (integration-enterprise, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (integration-mdm, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (integration-enterprise, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (integration-core, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-go (integration-mdm, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: publish
  • GitHub Check: test-packaging (ubuntu-latest, local)
  • GitHub Check: test-go (fleetctl, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (integration-core, ubuntu-latest, mysql:9.3.0, false)
  • GitHub Check: test-go (fast, ubuntu-latest, mysql:8.0.36, false)
  • GitHub Check: test-packaging (ubuntu-latest, remote)
  • GitHub Check: build-binaries
  • GitHub Check: lint (windows-latest)
  • GitHub Check: lint (ubuntu-latest)
  • GitHub Check: lint (macos-latest)
  • GitHub Check: test-go-nanomdm

@codecov

codecov Bot commented Jul 7, 2025

Copy link
Copy Markdown

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.07%. Comparing base (dbd6a23) to head (d7c2f1e).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30595      +/-   ##
==========================================
- Coverage   64.07%   64.07%   -0.01%     
==========================================
  Files        1878     1878              
  Lines      184482   184519      +37     
  Branches     5399     5399              
==========================================
+ Hits       118213   118233      +20     
- Misses      56948    56964      +16     
- Partials     9321     9322       +1     
Flag Coverage Δ
backend 65.05% <100.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@ghernandez345
ghernandez345 merged commit 499e4e3 into main Jul 7, 2025
@ghernandez345
ghernandez345 deleted the fix-gitops-eula-undefined-key branch July 7, 2025 17:20
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