Skip to content

Commit

Permalink
[Workspace] Clear the attribute of error objects (#9003) (#9012)
Browse files Browse the repository at this point in the history
* clear the attribute of error objects



* Changeset file for PR #9003 created/updated

* Changeset file for PR #9003 deleted

---------



(cherry picked from commit 36bf5e8)

Signed-off-by: yubonluo <yubonluo@amazon.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: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Dec 10, 2024
1 parent fe27288 commit 2405a28
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -429,9 +429,7 @@ describe('workspace_id_consumer integration test', () => {
]);
expect(bulkGetResultWithWorkspace.body.saved_objects[0]?.error).toBeUndefined();
expect(bulkGetResultWithWorkspace.body.saved_objects[1].id).toEqual('bar');
expect(bulkGetResultWithWorkspace.body.saved_objects[1].workspaces).toEqual([
createdBarWorkspace.id,
]);
expect(bulkGetResultWithWorkspace.body.saved_objects[1].workspaces).toBeUndefined();
expect(bulkGetResultWithWorkspace.body.saved_objects[1]?.error).toMatchInlineSnapshot(`
Object {
"error": "Forbidden",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ describe('WorkspaceIdConsumerWrapper', () => {
{
type: 'dashboard',
id: 'dashboard_id',
attributes: {},
references: [],
attributes: { description: 'description' },
references: ['reference_id'],
workspaces: ['foo'],
},
{
Expand All @@ -385,8 +385,8 @@ describe('WorkspaceIdConsumerWrapper', () => {
{
type: 'visualization',
id: 'visualization_id',
attributes: {},
references: [],
attributes: { description: 'description' },
references: ['reference_id'],
workspaces: ['bar'],
},
{
Expand Down Expand Up @@ -428,9 +428,13 @@ describe('WorkspaceIdConsumerWrapper', () => {
Object {
"saved_objects": Array [
Object {
"attributes": Object {},
"attributes": Object {
"description": "description",
},
"id": "dashboard_id",
"references": Array [],
"references": Array [
"reference_id",
],
"type": "dashboard",
"workspaces": Array [
"foo",
Expand All @@ -457,9 +461,6 @@ describe('WorkspaceIdConsumerWrapper', () => {
"id": "visualization_id",
"references": Array [],
"type": "visualization",
"workspaces": Array [
"bar",
],
},
Object {
"attributes": Object {},
Expand Down Expand Up @@ -506,9 +507,13 @@ describe('WorkspaceIdConsumerWrapper', () => {
Object {
"saved_objects": Array [
Object {
"attributes": Object {},
"attributes": Object {
"description": "description",
},
"id": "dashboard_id",
"references": Array [],
"references": Array [
"reference_id",
],
"type": "dashboard",
"workspaces": Array [
"foo",
Expand All @@ -535,9 +540,6 @@ describe('WorkspaceIdConsumerWrapper', () => {
"id": "visualization_id",
"references": Array [],
"type": "visualization",
"workspaces": Array [
"bar",
],
},
Object {
"attributes": Object {},
Expand Down Expand Up @@ -623,9 +625,13 @@ describe('WorkspaceIdConsumerWrapper', () => {
Object {
"saved_objects": Array [
Object {
"attributes": Object {},
"attributes": Object {
"description": "description",
},
"id": "dashboard_id",
"references": Array [],
"references": Array [
"reference_id",
],
"type": "dashboard",
"workspaces": Array [
"foo",
Expand All @@ -652,9 +658,6 @@ describe('WorkspaceIdConsumerWrapper', () => {
"id": "visualization_id",
"references": Array [],
"type": "visualization",
"workspaces": Array [
"bar",
],
},
Object {
"attributes": Object {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@ export class WorkspaceIdConsumerWrapper {
return this.validateObjectInAWorkspace(object, workspaces[0], wrapperOptions.request)
? object
: {
...object,
id: object.id,
type: object.type,
attributes: {} as T,
references: [],
error: {
...generateSavedObjectsForbiddenError().output.payload,
},
Expand Down

0 comments on commit 2405a28

Please sign in to comment.