-
Notifications
You must be signed in to change notification settings - Fork 30
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
Do not try to update custom fields if no custom field definitions exist #82
Conversation
Hi @tseeker Thank you for your work. I've tested in my environment with phpipam version 1.5.2.
Can you please add handling of status code |
Hello, Could you give me the Terraform source for the test you were running when receiving this message so I can test it on my end, please? Thank you! |
Issue reproduced on phpipam with version 1.4.1:
Updating hostname field for address:
I think it would be nice to add issue handling for previous versions of phpipam too. |
OK. I'll install phpIPAM 1.4.1 and test against it as well when I have some time. I'll update the PR when ready. Thank you! |
@tseeker what is the status here? Were you able to test again on 1.4.1? |
Hello, I'm sorry, I haven't had the time to work on it yet. |
@@ -114,8 +116,13 @@ func updateCustomFields(d *schema.ResourceData, client interface{}) error { | |||
panic(fmt.Errorf("Invalid client type passed %#v - this is a bug", client)) | |||
} | |||
if err != nil { | |||
return fmt.Errorf("Error getting custom fields for updating: %s", err) | |||
if strings.Contains(err.Error(), "404") && len(customFields) == 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose to change this condition to next to handle error from old phpipam versions:
if (strings.Contains(err.Error(), "404") || (strings.Contains(err.Error(), "200") && strings.Contains(err.Error(), "No custom fields defined")) && len(customFields) == 0 {
@tseeker you will have time to extend this condition?
This will allow as to accept your PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me. I won't have the time to test it properly in the foreseeable future though.
As per @pavel-z1 's suggestion.
@pavel-z1 I guess it is better you to review it finally. |
@tseeker Thank you for your work |
When no custom fields are defined on the phpIPAM instance, it is impossible to read (or write) custom fields from an object. Because of this, updates to addresses (and presumably VLANs and subnets) on instances without custom fields would fail with an
Error from API (404): No custom fields defined
, as described in #81.This patch ignores the error if the error above is returned by the API and no custom field values are to be set.