-
Notifications
You must be signed in to change notification settings - Fork 13.4k
chore!: change http code results for ddp over rest #38007
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
Changes from 14 commits
4a3b4b1
47def35
574aed8
ea7e639
44bc0b6
a2257f2
d03ff97
50dc670
1c767e0
f747ccd
676fab9
f2dac2d
dec5ffb
c828108
fe128b7
d50a169
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@rocket.chat/meteor': patch | ||
| --- | ||
|
|
||
| Changes the HTTP code of `/api/v1/method.call` and `/api/v1/method.callAnon` in case of internal errors | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -525,7 +525,8 @@ API.v1.addRoute( | |
| if (settings.get('Log_Level') === '2') { | ||
| Meteor._debug(`Exception while invoking method ${method}`, err); | ||
| } | ||
| return API.v1.success(mountResult({ id, error: err })); | ||
|
|
||
| return API.v1.failure(mountResult({ id, error: err })); | ||
| } | ||
| }, | ||
| }, | ||
|
|
@@ -580,7 +581,7 @@ API.v1.addRoute( | |
| if (settings.get('Log_Level') === '2') { | ||
| Meteor._debug(`Exception while invoking method ${method}`, err); | ||
| } | ||
| return API.v1.success(mountResult({ id, error: err })); | ||
| return API.v1.failure(mountResult({ id, error: err })); | ||
|
||
| } | ||
| }, | ||
| }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -166,9 +166,10 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
ggazzo marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| .expect((res) => { | ||
| expect(res.body).to.have.property('success', true); | ||
| expect(res.body).to.have.property('success', false); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.have.property('error').that.is.an('object'); | ||
| expect(data.error).to.have.property('error', 'error-action-not-allowed'); | ||
|
|
@@ -576,9 +577,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -734,9 +735,9 @@ describe('Meteor.methods', () => { | |
| msg: 'method', | ||
| }), | ||
| }) | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||
| expect(data.error).to.have.a.property('error', 'error-not-allowed'); | ||
|
|
@@ -903,9 +904,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -1121,9 +1122,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -1301,9 +1302,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -1562,9 +1563,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.include('error-invalid-room'); | ||
| }) | ||
| .end(done); | ||
|
|
@@ -1583,9 +1584,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.include('Match error'); | ||
| }) | ||
| .end(done); | ||
|
|
@@ -2022,9 +2023,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.property('success', true); | ||
| expect(res.body).to.have.property('success', false); | ||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.not.have.a.property('result').that.is.an('object'); | ||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||
|
|
@@ -2053,9 +2054,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.property('success', true); | ||
| expect(res.body).to.have.property('success', false); | ||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.have.a.property('error').that.is.an('object'); | ||
| expect(data.error.sanitizedError).to.have.a.property('reason', 'Match failed'); | ||
|
|
@@ -2241,9 +2242,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.have.a.property('msg').that.is.an('string'); | ||
|
|
@@ -2264,17 +2265,17 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
| const data = JSON.parse(res.body.message); | ||
| expect(data).to.have.a.property('msg').that.is.an('string'); | ||
| expect(data.error).to.have.a.property('error', 'error-action-not-allowed'); | ||
| }); | ||
| }); | ||
|
|
||
| it('should add a quote attachment to a message', async () => { | ||
| it.skip('should add a quote attachment to a message', async () => { | ||
| const quotedMsgLink = `${siteUrl}/group/${roomName}?msg=${messageWithMarkdownId}`; | ||
| await request | ||
| .post(methodCall('updateMessage')) | ||
|
|
@@ -2291,6 +2292,7 @@ describe('Meteor.methods', () => { | |
| .expect(200) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| // TODO: this test is not testing anything useful | ||
|
||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
| }); | ||
|
|
||
|
|
@@ -2378,7 +2380,7 @@ describe('Meteor.methods', () => { | |
| }); | ||
| }); | ||
|
|
||
| it('should remove a quote attachment from a message', async () => { | ||
| it.skip('should remove a quote attachment from a message', async () => { | ||
| await request | ||
| .post(methodCall('updateMessage')) | ||
| .set(credentials) | ||
|
|
@@ -2534,9 +2536,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -3098,7 +3100,7 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.property('message').that.is.an('string'); | ||
| expect(res.body.message).to.include('error-cant-invite-for-direct-room'); | ||
|
|
@@ -3201,9 +3203,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.property('success', true); | ||
| expect(res.body).to.have.property('success', false); | ||
| const parsedBody = JSON.parse(res.body.message); | ||
| expect(parsedBody).to.have.property('error'); | ||
| expect(parsedBody.error).to.have.property('error', 'error-max-rooms-per-guest-reached'); | ||
|
|
@@ -3225,9 +3227,9 @@ describe('Meteor.methods', () => { | |
| params: [[{ _id: 'Message_AllowEditing_BlockEditInMinutes', value: { $InfNaN: 0 } }]], | ||
| }), | ||
| }) | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.property('success', true); | ||
| expect(res.body).to.have.property('success', false); | ||
| const parsedBody = JSON.parse(res.body.message); | ||
| expect(parsedBody).to.have.property('error'); | ||
| expect(parsedBody.error).to.have.property('error', 'Invalid setting value NaN'); | ||
|
|
@@ -3333,7 +3335,7 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('message'); | ||
| const data = JSON.parse(res.body.message); | ||
|
|
@@ -3411,9 +3413,9 @@ describe('Meteor.methods', () => { | |
| }), | ||
| }) | ||
| .expect('Content-Type', 'application/json') | ||
| .expect(200) | ||
| .expect(400) | ||
| .expect((res) => { | ||
| expect(res.body).to.have.a.property('success', true); | ||
| expect(res.body).to.have.a.property('success', false); | ||
| expect(res.body).to.have.a.property('message').that.is.a('string'); | ||
|
|
||
| const data = JSON.parse(res.body.message); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Clarify the new HTTP response codes in the changeset description.
The description lacks specificity about what HTTP codes are now returned. Based on the PR objectives and summary, the endpoints should return 400 (and possibly other specific 40x codes) instead of 200, but this is not clear from the current text.
🔎 Suggested improvement
Or, if more specificity is needed:
This will make the changelog entry clearer for users reviewing release notes.
📝 Committable suggestion
🤖 Prompt for AI Agents