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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃悰Backwards Incompatible Change to fiber.Error #1767

Closed
swengineer404 opened this issue Feb 11, 2022 · 3 comments 路 Fixed by #1768
Closed

馃悰Backwards Incompatible Change to fiber.Error #1767

swengineer404 opened this issue Feb 11, 2022 · 3 comments 路 Fixed by #1768

Comments

@swengineer404
Copy link

swengineer404 commented Feb 11, 2022

Fiber version
2.26.0

Issue description
The change referenced here CLICK HERE in #1728 which was applied to a MINOR update is backwards incompatible. This change will break underlying structures that reference fiber.Error.Message using the concrete type "string".

One cannot simply imply that although the string can now be accessed via fiber.Message.Error() that this is a backwards-compatible change. The fact that code modification is needed by consumers in order to recorrect this issue is the exact representation of incompatibility.

This is not an argument of the effort required to fix or resolve this issue. It is merely a statement that semantic versioning is not being followed by this project if decisions/actions like this are being supported by the maintaining contributors.

Symantic versioning implies that both MINOR & PATCH updates must be done in a backwards compatible manner. This change is not backwards compatible in a typical scenario.

Changing the concrete type of publicly exposed API struct fields is bad practice for anything other than MAJOR backwards incompatible updates.

Code snippet

package main

import "github.com/gofiber/fiber/v2"

func ErrorHandler(c *fiber.Ctx, err error) error {
	var status int
	var message string

	switch e := err.(type) {
	case *fiber.Error:
		status = e.Code
		message = e.Message // This now throws an error because the concrete type of `Message` is no longer `string`
	default:
		status = http.StatusInternalServerError
		message = err.Error()
	}

	return c.Status(status).JSON(fiber.Map{"message": message})
}
@welcome
Copy link

welcome bot commented Feb 11, 2022

Thanks for opening your first issue here! 馃帀 Be sure to follow the issue template! If you need help or want to chat with us, join us on Discord https://gofiber.io/discord

@balcieren
Copy link
Contributor

Fiber version 2.26.0

Issue description The change referenced here CLICK HERE in #1728 which was applied to a MINOR update is backwards incompatible. This change will break underlying structures that reference fiber.Error.Message using the concrete type "string".

One cannot simply imply that although the string can now be accessed via fiber.Message.Error() that this is a backwards-compatible change. The fact that code modification is needed by consumers in order to recorrect this issue is the exact representation of incompatibility.

This is not an argument of the effort required to fix or resolve this issue. It is merely a statement that semantic versioning is not being followed by this project if decisions/actions like this are being supported by the maintaining contributors.

Symantic versioning implies that both MINOR & PATCH updates must be done in a backwards compatible manner. This change is not backwards compatible in a typical scenario.

Changing the concrete type of publicly exposed API struct fields is bad practice for anything other than MAJOR backwards incompatible updates.

Code snippet

package main

import "github.com/gofiber/fiber/v2"

func ErrorHandler(c *fiber.Ctx, err error) error {
	var status int
	var message string

	switch e := err.(type) {
	case *fiber.Error:
		status = e.Code
		message = e.Message // This now throws an error because the concrete type of `Message` is no longer `string`
	default:
		status = http.StatusInternalServerError
		message = err.Error()
	}

	return c.Status(status).JSON(fiber.Map{"message": message})
}

thanks for issue, I have thought. Message is going to be string and I will add new property for Error struct. It is going to be interface so you can use if you want string or interface.

@balcieren
Copy link
Contributor

@golangaddict #1768

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants