Skip to content

Commit

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

Signed-off-by: yubonluo <[email protected]>

* Changeset file for PR #9003 created/updated

* Changeset file for PR #9003 deleted

---------

Signed-off-by: yubonluo <[email protected]>
Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
  • Loading branch information
yubonluo and opensearch-changeset-bot[bot] authored Dec 5, 2024
1 parent 98e9042 commit 36bf5e8
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 @@ -485,9 +485,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 @@ -432,8 +432,8 @@ describe('WorkspaceIdConsumerWrapper', () => {
{
type: 'dashboard',
id: 'dashboard_id',
attributes: {},
references: [],
attributes: { description: 'description' },
references: ['reference_id'],
workspaces: ['foo'],
},
{
Expand All @@ -450,8 +450,8 @@ describe('WorkspaceIdConsumerWrapper', () => {
{
type: 'visualization',
id: 'visualization_id',
attributes: {},
references: [],
attributes: { description: 'description' },
references: ['reference_id'],
workspaces: ['bar'],
},
{
Expand Down Expand Up @@ -493,9 +493,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 @@ -522,9 +526,6 @@ describe('WorkspaceIdConsumerWrapper', () => {
"id": "visualization_id",
"references": Array [],
"type": "visualization",
"workspaces": Array [
"bar",
],
},
Object {
"attributes": Object {},
Expand Down Expand Up @@ -571,9 +572,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 @@ -600,9 +605,6 @@ describe('WorkspaceIdConsumerWrapper', () => {
"id": "visualization_id",
"references": Array [],
"type": "visualization",
"workspaces": Array [
"bar",
],
},
Object {
"attributes": Object {},
Expand Down Expand Up @@ -688,9 +690,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 @@ -717,9 +723,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 @@ -195,7 +195,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 36bf5e8

Please sign in to comment.