otterdog icon indicating copy to clipboard operation
otterdog copied to clipboard

Confusion between add/update (probably PUT/POST requests)

Open mbarbero opened this issue 5 months ago • 1 comments

In https://github.com/eclipse-tractusx/.eclipsefdn/pull/128, the changes were about re-aligning the configuration on file and the live settings.

The PR was adding variables to the configuration file, but the variables already existed in the live settings.

Otterdog tried to create (PUT?) the new variables, and failed because it was already existing. For it to succeed, it would have to try to update the variable (POST?)

I wonder if this is a scenario that Otterdog should support? Or is it just a bug with variables?

Project automotive.tractusx[github_id=eclipse-tractusx]
  there have been 66 validation infos, enable verbose output to display them.

+  add repo_variable[name="SONAR_ORGANIZATION", repository=bpdm] {
+    name  = "SONAR_ORGANIZATION"
+    value = "eclipse-tractusx"
+  }

+  add repo_variable[name="SONAR_PROJECT_KEY", repository=bpdm] {
+    name  = "SONAR_PROJECT_KEY"
+    value = "eclipse-tractusx_bpdm"
+  }

  
  Applying changes:

-                                                                                                             
- Error:   failed to apply patch: ADD- repo_variable[name="SONAR_ORGANIZATION", repository=bpdm]             
-          failed to add repo variable 'SONAR_ORGANIZATION': {"message":"Already exists- Variable already    
-          exists","documentation_url":"https://docs.github.com/rest/actions/variables#create-a-repository-…  
-                                                                                                             

-                                                                                                             
- Error:   failed to apply patch: ADD- repo_variable[name="SONAR_PROJECT_KEY", repository=bpdm]              
-          failed to add repo variable 'SONAR_PROJECT_KEY': {"message":"Already exists- Variable already     
-          exists","documentation_url":"https://docs.github.com/rest/actions/variables#create-a-repository-…  
-                                                                                                             

mbarbero avatar Jul 03 '25 08:07 mbarbero

when applying changes via a PR, otterdog does not run changes compared to the live settings, but to the current version of the config so speed up things and only apply the changes that have been approved and merged.

So in this case, otterdog thinks the variables do not exist yet and does a POST instead of a PUT operation as it would do when modifying an existing secret.

To avoid that, run otterdog in the cli.

I would never create PRs to align the config to live settings. If there is a misalignment, apply locally and push the config to the repo afterwards.

Otterdog could be changed to better handle that ofc, but for now the idea is to fix misalignment via the cli.

netomi avatar Jul 04 '25 13:07 netomi