apigee / apigee-config-maven-plugin

apigee-config-maven-plugin
Apache License 2.0
56 stars 108 forks source link

Support for space in entry name for KVM #214

Closed Jimbo51000 closed 1 month ago

Jimbo51000 commented 1 month ago

I am getting a http ERROR

"code": 409, "message": "KeyValueMapEntry TestMap__Test PPP already exists in map testsite_kvmap", { "@type": "type.googleapis.com/google.rpc.PreconditionFailure", "violations": [ { "type": "keyvaluemap.service.KeyValueMapEntryAlreadyExists", } ] }, when trying to update the value of this entry in my resources kvm org config folder in kvms.json file. A kvm entry with name "TestMap__Test PPP" already exists in the runtime kvm map. I believe this issue happens because the mvn plugin is making a POST request to create an entry without deleting it first. This would not have happened if the kvm name was in the list of existingKVM entries fetched with RestUtils. Is there an issue in fetching the current runtime KVM entries with your RestUtils that doesn't consider spaces in kvm entry name? image

ssvaidyanathan commented 1 month ago

@Jimbo51000 - can you please share the version you are using and the command you are running?

Jimbo51000 commented 1 month ago

i am using 2.8.1 and command is : mvn -X apigee-config:keyvaluemaps -Pcicd -Dfile=$APIGEE_TARGET_TOKEN -Dorg=$APIGEE_ORG -Dapigee.config.options=update -Dapigee.config.dir=$kvm_path -Dapigee.kvm.override=false

ssvaidyanathan commented 1 month ago

-Dapigee.kvm.override=false --> why are you passing that. Thats why its skipping

Check the plugin README

-Dapigee.kvm.override=true|false
     is used only when -Dapigee.config.options=update. 
     It overrides the KVM entries even if there are no changes. 
     Default is true. If set to false, it skips the entry update.
Jimbo51000 commented 1 month ago

This config works for kvm entry updates where key names do not have space in them. And I believe we had an earlier thread : https://github.com/apigee/apigee-config-maven-plugin/issues/207#issuecomment-2161647865 for why we needed the override,

ssvaidyanathan commented 1 month ago

so TestMap__Test PPP is a key and not the map name right?

Jimbo51000 commented 1 month ago
  {
    "name": "TestMap__Test PPP",
    "value": "test3"
  }

  This is the entry for the KVM map. And yes, it is a key name not a kvm map name.
ssvaidyanathan commented 1 month ago

so just to be clear, this entry is not present in the map currently... and you are trying to push this using the "update" option, correct?

Jimbo51000 commented 1 month ago

The entry is currently present in the runtime and went through in the first run of the plugin call. This was because the entry was absent in the runtime and the POST call from mvn created a new entry. The problem here is the mvn plugin is still making that POST call eventhough the entry exists. This should just be an regular update as any and have tried different kvm name characters. Space seems to throw the error.

ssvaidyanathan commented 1 month ago

Ok - must be a bug in the way how I check the entry:value will fix and provide an update

Jimbo51000 commented 1 month ago

Thanks. Please keep us posted.

ssvaidyanathan commented 1 month ago

Just released v2.9.1 Can you test your cases with that and let me know if its working as expected.

Jimbo51000 commented 1 month ago

thanks. works.