You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Marshal With is expecting the params in reponse #618
I am writing an endpoint where two params are part of the url
Code
schedule_api=Namespace(
"schedule",
description="API for all the League's Schedule queries"
)
schedule_payload=schedule_api.model('Schedule', {
'away_team': fields.String(
description="The name of the away team",
),
'away_team_id': fields.Integer(
description="The id of the away team",
),
'date': fields.Date(
description="The date of the game",
),
'field': fields.String(
description="The field of the game",
),
'home_team': fields.String(
description="The name of the home team",
),
'home_team_id': fields.Integer(
description="The id of the home team",
),
'league_id': fields.Integer(
description="The id of the league",
),
'score': fields.String(
description="The score of the game if played",
),
'status': fields.String(
description="The status of the game",
),
'time': fields.String(
description="The time of the game (Format: HH-MM)",
example="12:01"
),
})
pagination=get_pagination(schedule_api)
schedule_pagination=schedule_api.inherit("SchedulePagination", pagination, {
'items': fields.List(fields.Nested(schedule_payload))
})
@schedule_api.route("/<int:year>/<int:league_id>", endpoint="rest.schedule")@schedule_api.doc(params={"year": "The schedule year", "league_id": "The id of the league"})classScheduleAPIX(Resource):
@schedule_api.marshal_with(schedule_pagination, envelope='resource')defget(self, year, league_id):
page=request.args.get('page', 1, type=int)
data=pull_schedule(year, league_id, page=page)
# running into issue where say this was needed in response# just added them for nowdata['year'] =yeardata['league_id'] =league_idreturndata
Repro Steps (if applicable)
...
...
Broken!
Expected Behavior
Should be able to not include league_id and year in the response
Actual Behavior
[A description of the unexpected, buggy behavior.](root:errors_handler.py:86 Could not build url for endpoint 'rest.schedule' with values ['has_next', 'has_prev', 'items', 'pages', 'total']. Did you forget to specify values ['league_id', 'year']?)
Error Messages/Stack Trace
[A description of the unexpected, buggy behavior.](root:errors_handler.py:86 Could not build url for endpoint 'rest.schedule' with values ['has_next', 'has_prev', 'items', 'pages', 'total']. Did you forget to specify values ['league_id', 'year']?)
Environment
Python version 3.10.12
Flask version 2.2.3
Flask-RESTX version 1.3.0
Other installed Flask extensions
Additional Context
This is your last chance to provide any pertinent details, don't let this opportunity pass you by!
I was able to reproduce the behavior by adding a regression test with a route that has two required path parameters (similar to /int:year/int:league_id).
The exception originates from flask_restx.fields.Url.output(), where url_for() is called:
When the marshalled object does not contain the required route parameters, Flask raises a BuildError. Currently, Url.output() only catches TypeError and wraps it as MarshallingError, so the BuildError propagates.
Before preparing a PR, I'd like to clarify the expected behavior:
Should this case also be wrapped as a MarshallingError, or is propagating BuildError the intended behavior?
Activity
chinmay655 commentedon Jul 9, 2026
Hi! I'd like to work on this issue if it's still available.
chinmay655 commentedon Jul 9, 2026
Hi! I investigated this issue locally.
I was able to reproduce the behavior by adding a regression test with a route that has two required path parameters (similar to /int:year/int:league_id).
The exception originates from flask_restx.fields.Url.output(), where url_for() is called:
url_for(endpoint, _external=self.absolute, **data)
When the marshalled object does not contain the required route parameters, Flask raises a BuildError. Currently, Url.output() only catches TypeError and wraps it as MarshallingError, so the BuildError propagates.
Before preparing a PR, I'd like to clarify the expected behavior:
Should this case also be wrapped as a MarshallingError, or is propagating BuildError the intended behavior?