Skip to content
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

docs: remove attributes. in SavedObjectsFindOptions.fields example #4695

Merged
merged 3 commits into from
Jun 5, 2024

Conversation

joshuali925
Copy link
Member

Description

Corrects the example in the comment for SavedObjectsFindOptions. The comment is misleading because it includes attributes, which will be a field in the response

{
  "id": "my-pattern",
  "type": "index-pattern",
  "version": 1,
  "attributes": {
    "title": "my-pattern-*"
  }
}

But the raw document does not include attributes field, saved object client will put fields under saved object type in the raw document as the attributes field.

Raw document sample:

      {
        "_index": ".kibana_92668751_admin_5",
        "_id": "custom-type:185348a0-3239-11ee-b9f0-0fc7f32be0b4",
        "_seq_no": 106,
        "_primary_term": 2,
        "_score": null,
        "_source": {
          "custom-type": {
            "title": "custom title",
            "version": 1,
            "createdTimeMs": 1691093129770,
          },
          "type": "custom-type",
          "references": [],
          "updated_at": "2023-08-03T20:05:29.770Z"
        }
      },

So including attributes.<field> (e.g. attributes.title) in find options will not give correct results. Using <field> (e.g. title) is enough because the type will be prepended.

return [...acc, ...sourceFields.map((f) => `${t}.${f}`)];

Issues Resolved

Screenshot

Testing the changes

Check List

  • All tests pass
    • yarn test:jest
    • yarn test:jest_integration
    • yarn test:ftr
  • New functionality includes testing.
  • New functionality has been documented.
  • Update CHANGELOG.md
  • Commits are signed per the DCO using --signoff

Signed-off-by: Joshua Li <joshuali925@gmail.com>
@codecov
Copy link

codecov bot commented Aug 8, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 66.50%. Comparing base (46d7c2d) to head (86d131b).
Report is 307 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4695   +/-   ##
=======================================
  Coverage   66.50%   66.50%           
=======================================
  Files        3403     3403           
  Lines       65026    65026           
  Branches    10401    10401           
=======================================
+ Hits        43243    43245    +2     
+ Misses      19214    19213    -1     
+ Partials     2569     2568    -1     
Flag Coverage Δ
Linux_1 34.82% <ø> (ø)
Linux_2 55.31% <ø> (ø)
Linux_3 44.61% <ø> (+<0.01%) ⬆️
Linux_4 34.89% <ø> (ø)
Windows_1 34.83% <ø> (ø)
Windows_2 55.27% <ø> (ø)
Windows_3 44.61% <ø> (ø)
Windows_4 34.89% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@joshuali925
Copy link
Member Author

+ Coverage 66.10% 66.14% +0.03%

why does coverage change when the commit only changes a comment?

@joshuarrrr
Copy link
Member

+ Coverage 66.10% 66.14% +0.03%

why does coverage change when the commit only changes a comment?

CodeCov has some margin of error - we often see diffs for changes that have no test changes at all. Don't worry about it.

@joshuarrrr joshuarrrr added Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry backport 2.x v2.11.0 labels Sep 22, 2023
Copy link
Member

@joshuarrrr joshuarrrr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kavilla
Copy link
Member

kavilla commented Sep 26, 2023

@joshuali925 do you think there is a potential for some recent change to have modified this behavior or is it a potential weird behavior in the current client?

Was playing around with the import saved objects API and attempting to hit that endpoint with a POST without attributes actually got rejected explicitly telling me i need to include attributes.

If I was to implement an OpenSearch Dashboards client I would probably ensure that the usage is consistent so users don't have to modify data to include specific keys that we already map in another endpoint.

To be honest your point makes more sense but it makes me question if something off is happening somewhere.

@joshuali925
Copy link
Member Author

@kavilla I'm not sure why the rest API and saved object js client are inconsistent, I've not used the rest API much. But I don't think it's a recent change on the client, the related code I posted has not changed for more than 4 years

side question, where is the documentation for saved object rest API? I couldn't find them in https://opensearch.org/docs/latest/dashboards/index/

@joshuarrrr
Copy link
Member

side question, where is the documentation for saved object rest API? I couldn't find them in https://opensearch.org/docs/latest/dashboards/index/

opensearch-project/documentation-website#3799 😢

@kavilla
Copy link
Member

kavilla commented Sep 27, 2023

side question, where is the documentation for saved object rest API? I couldn't find them in https://opensearch.org/docs/latest/dashboards/index/

Yeah as @joshuarrrr commented it is to be added. I can try to scrap something together today.

@joshuarrrr
Copy link
Member

@kavilla Assigning to you to either finish the final review or provide updated docs and close.

@kavilla
Copy link
Member

kavilla commented Apr 2, 2024

@joshuali925, could this be the result of the type of dashboard is a container of other saved objects and so it is has different fields whereas the index pattern is a little bit more simplified?

If so then perhaps we can update this PR so that it references both examples

@kavilla kavilla added the needs more info Requires more information from poster label Apr 2, 2024
@joshuali925
Copy link
Member Author

@kavilla to be honest i don't remember the details or i didn't test on all types of saved objects, but based on the code i don't see the serialization logic changing for different object types.

@kavilla
Copy link
Member

kavilla commented Apr 30, 2024

im currently looking into this area so I'm going to move it to 2.15 and add it to the the saved objects OE.

@kavilla kavilla added v2.15.0 and removed v2.14.0 labels Apr 30, 2024
@BionIT BionIT merged commit 31b79e4 into opensearch-project:main Jun 5, 2024
79 of 81 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Jun 5, 2024
…4695)

Signed-off-by: Joshua Li <joshuali925@gmail.com>
Co-authored-by: Josh Romero <rmerqg@amazon.com>
(cherry picked from commit 31b79e4)
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
zhyuanqi pushed a commit that referenced this pull request Jun 5, 2024
…4695) (#6917)

(cherry picked from commit 31b79e4)

Signed-off-by: Joshua Li <joshuali925@gmail.com>
Signed-off-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Josh Romero <rmerqg@amazon.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport 2.x first-time-contributor needs more info Requires more information from poster Skip-Changelog PRs that are too trivial to warrant a changelog or release notes entry v2.15.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants