I have an issue with using Ruby SDK to add a dataset to a project.
I’m following those docs: https://sdk.gooddata.com/gooddata-ruby-doc/docs/advanced_blueprint_examples#playing-with-computed-attributes with sample code like below
blueprint = project.blueprint
update = GoodData::Model::ProjectBlueprint.build('update') do |p|
p.add_dataset('dataset.mynewdataset') do |d|
d.add_attribute(attribute_id, title: attribute_title)
# other attributes
new_blueprint = blueprint.merge(update)
But every time I’m getting an error saying, that some object already exists, each time giving a different object id for the original blueprint. So it looks like it was trying to duplicate already existing objects instead of only adding a new dataset. I see there’s an option to pass update preference, but I don’t want to allow cascade drops as I don’t want to risk loosing current data model.
Do you have any suggestions on what I may be doing wrong?
Best answer by Marek HorvátView original
This is Marek from Technical Support Team. Thank you for reaching out with this.
I will go ahead and replicate the issue you are having with this code sample and reach back to you once I figure out what is going on here.
I looked into this and it seems that some of the datasets in the original blueprint have the same ID as the new dataset you are trying to add, which is why are you seeing these errors. Another possibility is that you are using already existing attribute/fact identifiers, which are unique per workspace.
Would it please be possible to share the full error message that is being raised (you can obfuscate the actual IDs)?
You might try this instead (as taken from the example from our docs):
Please let us know if this helps.
Also, you can always run a validate() method on the blueprint before calling update_from_blueprint() to ensure the blueprint is indeed valid.
Hello, so I double checked and unfortunately I still have the same issue.
Here’s my additional test dataset I want to add:
Validation returned an empty array. The error I get is GoodData::MaqlExecutionError (Unable to migrate LDM, reason(s): )
Object 'attr.project.projectcustomtextfield1' already exists
Where `attr.project.projectcustomtextfield1` is indeed already existing id but it’s not in my update. After running `udpate_from_blueprint` whole MAQL was displayed and there were a lot of ALTER DATASET but also CREATE FACT and CREATE ATTRIBUTE definitions referring already existing fields in the original blueprint.
Can it be some setting on the workspace that causes such behaviour? It was generated by cloning from production account, but normally we’re using provision/release/rollout lifecycle.
I’ve actually made one another test and updated blueprint for my template workspace, and for that one the update went without issues. So I suppose there is something about my workspace config that causes the problem
Thank you for the clarification! If the cloned workspace came from a workspace that is managed by LCM (provision/release/rollout lifecycle), it is most likely caused by the metadata flag `_lcm_managed_object:true`. Essentially, all metadata elements managed by LCM are tagged with this flag, which might cause some unexpected behavior, as objects tagged with this flag cannot be manipulated.
Could you please check whether the original project blueprint’s metadata had such flags? You can find it in the metadata object’s grey page. The best way to get there is to use our GoodData Chrome Extension tool (available here, more information here).
You can check it like this: