fix: tolerate a null StandardChangeTemplateName from the server - #220
Open
susanpann wants to merge 4 commits into
Open
fix: tolerate a null StandardChangeTemplateName from the server#220susanpann wants to merge 4 commits into
susanpann wants to merge 4 commits into
Conversation
tothegills
reviewed
Nov 14, 2023
| IsStateAutomaticallyTransitioned bool | ||
| StandardChangeTemplateName string | ||
| IsStateAutomaticallyTransitioned bool `json:"AutomaticStateTransition"` | ||
| StandardChangeTemplateName string `json:"StandardChangeTemplateName,omitempty"` |
Contributor
There was a problem hiding this comment.
Can you describe how this relates to the issue?
Contributor
Author
There was a problem hiding this comment.
I don't know if it's a required change, but I thought to add the omitempty to mimic what the UI does when sending the request. ie. If the standard template name isn't provided it leaves that field out of the request.
tothegills
approved these changes
Nov 14, 2023
The struct tags added here had no effect: ServiceNowExtensionSettings has a custom MarshalJSON that builds the Values map by hand and never consults them, so the wire format was unchanged. Omitting the key isn't the fix either. The server stores Values verbatim and treats an empty StandardChangeTemplateName as "no standard change template", so an empty string already works, and the portal reads the key back without guarding against it being absent. What does break is reading a project whose value is null, which UnmarshalJSON asserted straight to a string and panicked on. Check the type instead. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
NickJosevski
force-pushed
the
susan/serviceNow
branch
from
August 14, 2026 05:04
33da535 to
0fe193e
Compare
JiraServiceManagementExtensionSettings.UnmarshalJSON had the same unchecked type assertions as the ServiceNow settings. A project that isn't change controlled skips server-side validation entirely, so a null ServiceDeskProjectName can be stored and panics on read. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The test built its input with extensions.ServiceNowExtensionID. Nothing asserted the extension ID, so the mistake went unnoticed; assert it now. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relates to OctopusDeployLabs/terraform-provider-octopusdeploy#574
Changes direction from the original commit. The
omitemptytags had no effect —ServiceNowExtensionSettingshas a customMarshalJSONthat builds theValuesmap by hand and never reads struct tags, so the wire format was identical before and after.Omitting the key isn't the fix either. The server stores
Valuesverbatim and resolves the template withstring.IsNullOrWhiteSpace, so an empty string already means "no standard change template". The portal readsValues.StandardChangeTemplateName.trim()unconditionally, so a project written without the key would break the ITSM settings page.What actually breaks is reading a project whose value is null —
UnmarshalJSONasserted straight to a string and panicked withinterface conversion: interface {} is nil, not string. Values are now type-checked before assigning.Three commits:
UnmarshalJSON.ServiceDeskProjectNamecan be stored and panics on read.TestJiraServiceManagementExtensionSettingsUnmarshalJSONbuilt its input withServiceNowExtensionID; nothing asserted the extension ID, so it went unnoticed.Verified against a local instance for both extensions: a project with a null value panicked before and now reads back as empty, and a create/update/re-read round-trip is accepted and stable.