Closed mehanoid closed 10 months ago
@mehanoid Thank you for pointing out. Yes, location
is a valid option for render
so this should be fixed.
The problem is how to fix it. As you mentioned only
and except
are confusing but others are not, so we can warn only about those two options.
I believe this warning itself is valuable since some people will expect only
and except
work and they submit bug reports because they don't work.
I think warning about these two options would be much better than the current implementation anyway. It would also be more resilient to possible future changes in the rails api.
@mehanoid I noticed that methods
option could be also confusing. What do you think about it?
It seems to me that we should be guided by the potential usecases and the result someone might expect when using these options. The only
and except
options would obviously be expected to render only the specified attributes. But what would be expected when passing the methods
option? That the specified methods would be called on the Resource instance? That seems a bit odd.
Makes sense. I'll start with only
and except
only, and when people think we should add methods
to that list, I'll do so.
Describe the bug
When using the
location
option in therender
method, a warning is shownTo Reproduce
Expected behavior
No warnings
Actual behavior
The following message is shown:
Environment
Additional context
location
is a valid option for therender
method. In the code there is a whitelist of options for which alba does not show warnings. Among them there is nolocation
option. I think that at least thelocation
option should be added to the whitelist too.Although perhaps it would be better to blacklist the options for which the warning will be shown? As I understand it, the warning was originally added to avoid confusion with the
only
orexcept
options, which can be mistakenly added, expecting that only the specified attributes will be shown in the server response.At the same time, it is arguable whether any warnings are necessary at all. Rails itself does not do any checks for invalid options. Should alba take over this responsibility?