Skip to content

fix: change Tags from []string to []Tag for transformations, analytic-templates and command-templates#205

Open
davhparry wants to merge 1 commit into
itential:mainfrom
davhparry:fix/mop-export-tag-error
Open

fix: change Tags from []string to []Tag for transformations, analytic-templates and command-templates#205
davhparry wants to merge 1 commit into
itential:mainfrom
davhparry:fix/mop-export-tag-error

Conversation

@davhparry

Copy link
Copy Markdown
Contributor
  • Exporting transformations, analytic-templates, and command-templates that had tags assigned failed with json: cannot unmarshal object into Go struct field .tags of type string. The platform API returns tags as objects ({_id, name, description}) but the structs declared Tags []string.

Description

Type of Change

  • Bug fix
  • New feature
  • Documentation
  • Refactor
  • Chore

Changes Made

  • Changed Tags field type from []string to []Tag on Transformation, AnalyticTemplate, and CommandTemplate structs.
  • Initialised Tags: []Tag{} in each factory function (NewTransformation, NewAnalyticTemplate, NewCommandTemplate) so newly created assets emit "tags": [], matching the platform API behaviour.

Testing

make test passes with no failures- done
Export a transformation, analytic-template, or command-template that has tags assigned — verify tags are preserved in the exported file - done
Import the exported file back — verify import succeeds without unmarshal errors - done
Export an asset with no tags — verify the output contains "tags": [] rather than omitting the field - done
New unit tests added for all three resource types covering: export with tags, export with empty tags, import with tags, and factory initialization

Related Issues

Closes: 201

Checklist

  • [ x] Code follows the project's style guidelines
  • [ x] Self-review of code has been performed
  • [ x] Code has been commented where necessary
  • [ x] Tested with make setup or relevant profile
  • [ x] Commits follow conventional format (type: subject)
  • [ x] No secrets or credentials committed
  • [ x] Documentation has been updated accordingly
  • [ x] PR has been labeled appropriately (enhancement, bug, documentation, refactor, chore)

…-templates and command-templates

Exporting assets with tags caused an unmarshal error because Tags was
typed as []string, but the platform API returns tag objects with _id,
name and description fields. Changed Tags to []Tag on Transformation,
AnalyticTemplate and CommandTemplate structs, and initialised the field
to []Tag{} in each factory function so newly created assets emit
"tags": [] to match the API.
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.

bug: Exporting command-template with a tag throws a ' cannot unmarshal object into Go struct' error

1 participant